59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PartReplacement extends Model
|
|
{
|
|
protected $table = 'maintenance_part_replacements';
|
|
|
|
protected $fillable = [
|
|
'business_id', 'equipment_id', 'equipment_part_id', 'spare_part_id', 'replaced_at',
|
|
'quantity', 'action', 'health_before', 'health_after', 'replacement_quality_grade',
|
|
'performed_by', 'service_record_id', 'approval_id', 'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'replaced_at' => 'date',
|
|
'quantity' => 'decimal:3',
|
|
'health_before' => 'decimal:2',
|
|
'health_after' => 'decimal:2',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{ }
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function equipment()
|
|
{
|
|
return $this->belongsTo(Equipment::class, 'equipment_id');
|
|
}
|
|
|
|
public function equipmentPart()
|
|
{
|
|
return $this->belongsTo(EquipmentPart::class, 'equipment_part_id');
|
|
}
|
|
|
|
public function sparePart()
|
|
{
|
|
return $this->belongsTo(SparePart::class, 'spare_part_id');
|
|
}
|
|
|
|
public function performer()
|
|
{
|
|
return $this->belongsTo(User::class, 'performed_by');
|
|
}
|
|
|
|
public function serviceRecord()
|
|
{
|
|
return $this->belongsTo(ServiceRecord::class, 'service_record_id');
|
|
}
|
|
}
|