57 lines
1.1 KiB
PHP
57 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SparePartConsumption extends Model
|
|
{
|
|
protected $table = 'maintenance_spare_part_consumptions';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'spare_part_id',
|
|
'work_order_id',
|
|
'equipment_id',
|
|
'quantity',
|
|
'unit_cost',
|
|
'notes',
|
|
'consumed_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:3',
|
|
'unit_cost' => 'integer',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{ }
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function sparePart()
|
|
{
|
|
return $this->belongsTo(SparePart::class, 'spare_part_id');
|
|
}
|
|
|
|
public function workOrder()
|
|
{
|
|
return $this->belongsTo(WorkOrder::class, 'work_order_id');
|
|
}
|
|
|
|
public function equipment()
|
|
{
|
|
return $this->belongsTo(Equipment::class, 'equipment_id');
|
|
}
|
|
|
|
public function consumer()
|
|
{
|
|
return $this->belongsTo(User::class, 'consumed_by');
|
|
}
|
|
}
|