<?php

namespace App\Models;

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

class Production extends Model
{
    use HasFactory;

    protected $fillable = ['*'];

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

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

    public function stocktransactionOut()
    {
        return $this->belongsTo(Stocktransaction::class, 'stocktransaction_id_out');
    }

    public function stocktransactions()
    {
        return $this->hasMany(Stocktransaction::class, 'production_id');
    }

    public function costs()
    {
        return $this->hasMany(ProductionCost::class, 'production_id');
    }
}
