86 lines
1.9 KiB
PHP
86 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Staudenmeir\EloquentEagerLimit\HasEagerLimit;
|
|
|
|
class Products extends Model
|
|
{
|
|
|
|
use HasEagerLimit;
|
|
|
|
protected $casts = [
|
|
'star' => 'boolean'
|
|
];
|
|
|
|
public function pictograms()
|
|
{
|
|
return $this->belongsToMany(
|
|
ProductPictograms::class,
|
|
"products_pictograms",
|
|
"id_product",
|
|
"id_pictogram"
|
|
);
|
|
}
|
|
|
|
public function range()
|
|
{
|
|
return $this->belongsTo(Ranges::class);
|
|
}
|
|
|
|
public function meatType()
|
|
{
|
|
return $this->belongsTo(MeatTypes::class, 'meat_type_id');
|
|
}
|
|
|
|
public function consumptionTimes()
|
|
{
|
|
return $this->belongsTo(ConsumptionTimes::class, 'consumption_times_id');
|
|
}
|
|
|
|
public function recipe()
|
|
{
|
|
return $this->belongsTo(Recipes::class);
|
|
}
|
|
|
|
public function country()
|
|
{
|
|
return $this->belongsTo(Countries::class, 'country_id ');
|
|
}
|
|
|
|
public function society()
|
|
{
|
|
return $this->belongsTo(Societies::class, 'society_id ');
|
|
}
|
|
|
|
public function saleFamily()
|
|
{
|
|
return $this->belongsTo(SalesFamilies::class, 'sale_family_id ');
|
|
}
|
|
|
|
public function incoNutritionalValues()
|
|
{
|
|
return $this->hasOne(IncoNutritionalValues::class, 'id_product');
|
|
}
|
|
|
|
public function balancedMenu()
|
|
{
|
|
return $this->hasOne(BalancedMenus::class, 'product_id');
|
|
}
|
|
|
|
public function recipes()
|
|
{
|
|
return $this->belongsToMany(Recipes::class, 'recipes_products', 'recipe_id', 'product_id');
|
|
}
|
|
|
|
public function customers()
|
|
{
|
|
return $this->belongsToMany(Customers::class, 'cart', 'product_id', 'customer_id');
|
|
}
|
|
|
|
public function reductions()
|
|
{
|
|
return $this->belongsToMany(Reductions::class, 'reduction_config', 'product_id', 'reduction_id');
|
|
}
|
|
}
|