45 lines
884 B
PHP
45 lines
884 B
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class WorkOrderPart extends Model
|
|
{
|
|
protected $table = 'maintenance_work_order_parts';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'work_order_id',
|
|
'spare_part_id',
|
|
'quantity',
|
|
'unit_cost',
|
|
'total_cost',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:3',
|
|
'unit_cost' => 'integer',
|
|
'total_cost' => 'integer',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{ }
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function workOrder()
|
|
{
|
|
return $this->belongsTo(WorkOrder::class, 'work_order_id');
|
|
}
|
|
|
|
public function sparePart()
|
|
{
|
|
return $this->belongsTo(SparePart::class, 'spare_part_id');
|
|
}
|
|
}
|