87 lines
2.2 KiB
PHP
87 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ServiceRecord extends Model
|
|
{
|
|
protected $table = 'maintenance_service_records';
|
|
|
|
protected $fillable = [
|
|
'business_id', 'equipment_id', 'project_id', 'production_line_id', 'work_order_id', 'overhaul_id', 'service_type',
|
|
'title', 'description', 'started_at', 'completed_at', 'labor_hours', 'cost',
|
|
'performed_by', 'repair_provider_id', 'commissioning_provider_id',
|
|
'health_before', 'health_after', 'approval_id', 'status',
|
|
];
|
|
|
|
protected $casts = [
|
|
'started_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'labor_hours' => 'decimal:2',
|
|
'cost' => 'integer',
|
|
'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 project()
|
|
{
|
|
return $this->belongsTo(\Modules\Project\Entities\Project::class, 'project_id');
|
|
}
|
|
|
|
public function productionLine()
|
|
{
|
|
return $this->belongsTo(ProductionLine::class, 'production_line_id');
|
|
}
|
|
|
|
public function workOrder()
|
|
{
|
|
return $this->belongsTo(WorkOrder::class, 'work_order_id');
|
|
}
|
|
|
|
public function overhaul()
|
|
{
|
|
return $this->belongsTo(Overhaul::class, 'overhaul_id');
|
|
}
|
|
|
|
public function performer()
|
|
{
|
|
return $this->belongsTo(User::class, 'performed_by');
|
|
}
|
|
|
|
public function repairProvider()
|
|
{
|
|
return $this->belongsTo(ServiceProvider::class, 'repair_provider_id');
|
|
}
|
|
|
|
public function commissioningProvider()
|
|
{
|
|
return $this->belongsTo(ServiceProvider::class, 'commissioning_provider_id');
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(ServiceRecordItem::class, 'service_record_id');
|
|
}
|
|
|
|
public function approval()
|
|
{
|
|
return $this->belongsTo(MaintenanceApproval::class, 'approval_id');
|
|
}
|
|
}
|