<?php

namespace App\Models;

use App\Enums\IngredientUnit;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class MealPostIngredients extends Model
{
    protected $fillable = [
        'meal_posts_id',
        'position',
        'ingredient',
        'quantity',
        'unit',
    ];

    public function mealPosts(): BelongsTo
    {
        return $this->belongsTo(MealPosts::class);
    }

    protected function casts(): array
    {
        return [
            'quantity' => 'integer',
            'unit' => IngredientUnit::class,
        ];
    }
}
