- article_category - article - eleveur - eleveurs_sites - survey_response - fos_user - aimant_user - content_ocb - encemoment_fiche - encemoment_strates - gamme - home_slider - home_mini_slider - moment_consommation - pays - type_viande - societe - famille_vente - produit - recipe - menu - produit (update) - pictos - pictosproducts - inco_composition - qrcode - product_slider - recipe Articles - reduction - products reductions - saga - user_favorite_recipe Introduces Enum system caster and trait Html Colors auto cast for HomeSliderPictures and Ranges All migrations struct, data and model traits except HomeSliderPicture Days enum system and HomeSliderPicture migration
47 lines
1,004 B
PHP
47 lines
1,004 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\RecipeDifficulty;
|
|
use App\Enums\RecipeType;
|
|
use App\Traits\CastsEnums;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Recipes extends Model
|
|
{
|
|
use CastsEnums;
|
|
|
|
protected $casts = [
|
|
'highlight' => 'boolean'
|
|
];
|
|
|
|
protected $enumCasts = [
|
|
'type' => RecipeType::class,
|
|
'difficulty' => RecipeDifficulty::class
|
|
];
|
|
|
|
public function articles()
|
|
{
|
|
return $this->belongsToMany(Articles::class);
|
|
}
|
|
|
|
public function products()
|
|
{
|
|
return $this->hasMany('App\Models\Products', 'recipe_id');
|
|
}
|
|
|
|
public function product1()
|
|
{
|
|
return $this->belongsTo('App\Models\Products', 'associated_product1');
|
|
}
|
|
|
|
public function product2()
|
|
{
|
|
return $this->belongsTo('App\Models\Products', 'associated_product2');
|
|
}
|
|
|
|
public function customers()
|
|
{
|
|
return $this->belongsToMany('App\Models\Customers', 'customer_recipe', 'recipe_id', 'customer_id');
|
|
}
|
|
}
|