Add new data in getBasket context

This commit is contained in:
Ludovic CANDELLIER
2022-04-24 23:20:52 +02:00
parent f3e9ccaa46
commit 6fc6451f6f
5 changed files with 41 additions and 22 deletions

View File

@@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Model;
use Znck\Eloquent\Traits\BelongsToThrough;
use App\Traits\Model\HasComments;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
class Offer extends Model
{
use BelongsToThrough, HasComments;
use BelongsToThrough, HasComments, HasRelationships;
protected $guarded = ['id'];
protected $table = 'shop_offers';
@@ -27,6 +28,26 @@ class Offer extends Model
]);
}
public function categories()
{
return $this->article->categories();
}
public function price_lists()
{
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
}
public function price_list_values()
{
return $this->hasManyDeep(
PriceListValue::class,
[Tariff::class, PriceList::class],
['id', 'tariff_id', 'price_list_id'],
['tariff_id', 'id', 'id'],
);
}
public function tariff()
{
return $this->belongsTo(Tariff::class);
@@ -37,16 +58,6 @@ class Offer extends Model
return $this->belongsTo(Variation::class);
}
public function price_lists()
{
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
}
public function categories()
{
return $this->article->categories();
}
public function tags()
{
return $this->article->tags();