This commit is contained in:
Ludovic CANDELLIER
2021-11-07 19:58:38 +01:00
parent c7c8e18cbc
commit 63c6671c97
22 changed files with 143 additions and 48 deletions

View File

@@ -10,7 +10,7 @@ class Shelve extends Model
use HasRelationships;
protected $guarded = ['id'];
protected $table = 'shop_shelves';
protected $table = 'shop_categories';
public function articles()
{

View File

@@ -5,6 +5,8 @@ namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
use App\Models\Botanic\Specie;
use App\Models\Botanic\Variety;
class Tag extends Model
{
@@ -25,19 +27,24 @@ class Tag extends Model
return $this->morphedByMany(Article::class, 'taggable');
}
public function varieties()
public function group()
{
return $this->morphedByMany(\App\Models\Botanic\Variety::class, 'taggable');
return $this->hasOne(TagGroup::class, 'id', 'tag_group_id');
}
public function shelves()
{
return $this->morphedByMany(Shelve::class, 'taggable');
}
public function species()
{
return $this->morphedByMany(\App\Models\Botanic\Specie::class, 'taggable');
return $this->morphedByMany(Specie::class, 'taggable');
}
public function group()
public function varieties()
{
return $this->hasOne(TagGroup::class, 'id', 'tag_group_id');
return $this->morphedByMany(Variety::class, 'taggable');
}
public function scopeByGroup($query, $id)

View File

@@ -21,6 +21,12 @@ class Tariff extends Model
return $this->belongsTo(SaleChannel::class);
}
public function sale_channels()
{
// return $this->HasManyThrough(SaleChannel::class, PriceList::class);
return $this->HasManyThrough(SaleChannel::class, PriceList::class, 'id', 'id', 'id', 'sale_channel_id');
}
public function tariff_unity()
{
return $this->belongsTo(TariffUnity::class);