<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProductionRecipe extends Model
{
    use HasFactory;

    protected $table = 'production_recipes';

    protected $fillable = [
        'product_finished_id',
        'product_material_id',
        'multi_unit_finished',
        'multi_unit_material',
        'qty_finished',
        'qty_material',
    ];

    public function productFinished()
    {
        return $this->belongsTo(Product::class, 'product_finished_id');
    }

    public function productMaterial()
    {
        return $this->belongsTo(Product::class, 'product_material_id');
    }

    public function unitFinished()
    {
        return $this->belongsTo(MultiUnit::class, 'multi_unit_finished');
    }

    public function unitMaterial()
    {
        return $this->belongsTo(MultiUnit::class, 'multi_unit_material');
    }

    public function multiunit()
    {
        return $this->belongsTo(MultiUnit::class, 'multi_unit_material');
    }
}
