Add deep relations

This commit is contained in:
Ludovic CANDELLIER
2022-01-14 00:03:21 +01:00
parent 95ca3c6404
commit 050fd76122
13 changed files with 159 additions and 30 deletions

View File

@@ -20,6 +20,20 @@ class PriceListValue extends Model
return $this->belongsTo(PriceList::class);
}
public function tariff()
{
return $this->belongsToThrough(
'App\Models\Shop\Tariff',
'App\Models\Shop\PriceList',
null,
'',
[
'App\Models\Shop\Tariff' => 'tariff_id',
'App\Models\Shop\PriceList' => 'price_list_id'
]
);
}
public function scopeByPriceList($query, $id)
{
return $query->where($this->table . '.price_list_id', $id);