23 lines
480 B
PHP
23 lines
480 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Ingredient extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'slug',
|
|
'category',
|
|
];
|
|
|
|
public function recipes(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Recipe::class, 'recipe_ingredient')
|
|
->withPivot('quantity', 'unit', 'notes', 'sort_order')
|
|
->withTimestamps();
|
|
}
|
|
}
|