<?php

namespace App\Models\Design;

use Illuminate\Database\Eloquent\Model;

class BomTemplateItem extends Model
{
    protected $table = 'bom_template_items';

    protected $fillable = [
        'tenant_id', 'bom_template_id', 'ref_type', 'ref_id', 'qty', 'waste_rate', 'uom_id', 'notes', 'sort_order',
        'is_calculated', 'calculation_formula', 'depends_on', 'calculation_config',
    ];

    protected $casts = [
        'qty' => 'decimal:6',
        'waste_rate' => 'decimal:6',
        'is_calculated' => 'boolean',
        'depends_on' => 'array',
        'calculation_config' => 'array',
    ];

    public function template()
    {
        return $this->belongsTo(BomTemplate::class, 'bom_template_id');
    }
}
