52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
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->belongsToMany(Products::class, 'recipes_products', 'product_id', 'recipe_id');
|
|
}
|
|
|
|
public function product1()
|
|
{
|
|
return $this->belongsTo(Products::class, 'associated_product1');
|
|
}
|
|
|
|
public function product2()
|
|
{
|
|
return $this->belongsTo(Products::class, 'associated_product2');
|
|
}
|
|
|
|
public function customers()
|
|
{
|
|
return $this->belongsToMany(Customers::class);
|
|
}
|
|
|
|
public function consumptionTimes()
|
|
{
|
|
return $this->belongsTo(ConsumptionTimes::class);
|
|
}
|
|
}
|