99 lines
2.3 KiB
PHP
99 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Products extends Model
|
|
{
|
|
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);
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function meat_type()
|
|
{
|
|
return $this->belongsTo(MeatTypes::class, 'meat_type_id');
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function consumption_times()
|
|
{
|
|
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 ');
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function sale_family()
|
|
{
|
|
return $this->belongsTo(SalesFamilies::class, 'sale_family_id ');
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function inco_nutritional_values()
|
|
{
|
|
return $this->hasOne(INCONutritionalValues::class);
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function balanced_menu()
|
|
{
|
|
return $this->hasOne(BalancedMenus::class, 'product_id');
|
|
}
|
|
|
|
public function recipes()
|
|
{
|
|
return $this->belongsToMany(Recipes::class, 'recipes_products', 'recipe_id', 'product_id');
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function recipes_associated_1()
|
|
{
|
|
return $this->hasMany(Recipes::class, 'associated_product1 ');
|
|
}
|
|
|
|
//TODO: PSR1 is not in camel caps format
|
|
public function recipes_associated_2()
|
|
{
|
|
return $this->hasMany(Recipes::class, 'associated_product2 ');
|
|
}
|
|
|
|
public function customers()
|
|
{
|
|
return $this->belongsToMany(Customers::class, 'cart');
|
|
}
|
|
|
|
public function reductions()
|
|
{
|
|
return $this->belongsToMany(Reductions::class, 'reduction_config');
|
|
}
|
|
}
|