<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Recipe extends Model
{
    protected $fillable = [
        'product_id',
        'ingredient_id',
        'usage_qty',
        'variant',
    ];

    protected $casts = [
        'usage_qty' => 'decimal:4',
    ];

    /**
     * Get the product that uses this recipe element.
     */
    public function product(): BelongsTo
    {
        return $this->belongsTo(Product::class);
    }

    /**
     * Get the ingredient required by this recipe element.
     */
    public function ingredient(): BelongsTo
    {
        return $this->belongsTo(Ingredient::class);
    }
}
