63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\IndustrialEngineering\Models;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\IndustrialEngineering\Services\LiveBomCostingService;
|
|
|
|
class Bom extends Model
|
|
{
|
|
use BelongsToBusiness;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'ie_boms';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'released_at' => 'datetime',
|
|
];
|
|
|
|
public function lineRevision()
|
|
{
|
|
return $this->belongsTo(LineRevision::class, 'line_revision_id');
|
|
}
|
|
|
|
public function itemMaster()
|
|
{
|
|
return $this->belongsTo(ItemMaster::class, 'item_master_id');
|
|
}
|
|
|
|
public function lines()
|
|
{
|
|
return $this->hasMany(BomLine::class, 'bom_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function rootLines()
|
|
{
|
|
return $this->hasMany(BomLine::class, 'bom_id')->whereNull('parent_line_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function changeRequests()
|
|
{
|
|
return $this->hasMany(BomChangeRequest::class, 'bom_id');
|
|
}
|
|
|
|
public function effectivities()
|
|
{
|
|
return $this->hasMany(BomEffectivity::class, 'bom_id');
|
|
}
|
|
|
|
/**
|
|
* Legacy helper used by older MRP controllers.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function get_bom_details(float $plannedQty = 1.0, ?int $locationId = null): array
|
|
{
|
|
return app(LiveBomCostingService::class)->analyze($this, $plannedQty, $locationId);
|
|
}
|
|
}
|