46 lines
955 B
PHP
46 lines
955 B
PHP
<?php
|
|
|
|
namespace Modules\IndustrialEngineering\Models;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class EngineeringChangeOrder extends Model
|
|
{
|
|
use BelongsToBusiness;
|
|
|
|
protected $table = 'ie_engineering_change_orders';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'impact_cost_delta' => 'decimal:4',
|
|
'effective_at' => 'datetime',
|
|
];
|
|
|
|
public function lineRevision()
|
|
{
|
|
return $this->belongsTo(LineRevision::class, 'line_revision_id');
|
|
}
|
|
|
|
public function bom()
|
|
{
|
|
return $this->belongsTo(Bom::class, 'bom_id');
|
|
}
|
|
|
|
public function requestedBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'requested_by');
|
|
}
|
|
|
|
public function approvedBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_by');
|
|
}
|
|
|
|
public function effectiveCode(): string
|
|
{
|
|
return $this->eco_number ?: ($this->auto_code ?: 'ECO-'.$this->id);
|
|
}
|
|
}
|