58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\IndustrialEngineering\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BomLine extends Model
|
|
{
|
|
use BelongsToBusiness;
|
|
|
|
protected $table = 'ie_bom_lines';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:4',
|
|
'standard_cost' => 'decimal:4',
|
|
'is_optional' => 'boolean',
|
|
'is_serviceable' => 'boolean',
|
|
'warranty_policy' => 'array',
|
|
];
|
|
|
|
public function bom()
|
|
{
|
|
return $this->belongsTo(Bom::class, 'bom_id');
|
|
}
|
|
|
|
public function parentLine()
|
|
{
|
|
return $this->belongsTo(BomLine::class, 'parent_line_id');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(BomLine::class, 'parent_line_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function itemMaster()
|
|
{
|
|
return $this->belongsTo(ItemMaster::class, 'item_master_id');
|
|
}
|
|
|
|
public function itemRevision()
|
|
{
|
|
return $this->belongsTo(ItemRevision::class, 'item_revision_id');
|
|
}
|
|
|
|
public function alternates()
|
|
{
|
|
return $this->hasMany(BomLineAlternate::class, 'bom_line_id');
|
|
}
|
|
|
|
public function preferredSupplier()
|
|
{
|
|
return $this->belongsTo(Supplier::class, 'preferred_supplier_id');
|
|
}
|
|
}
|