104 lines
2.3 KiB
PHP
104 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class WorkOrder extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'maintenance_work_orders';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'equipment_id',
|
|
'project_id',
|
|
'production_line_id',
|
|
'preventive_schedule_id',
|
|
'overhaul_id',
|
|
'rebuild_id',
|
|
'work_order_number',
|
|
'requester_id',
|
|
'assigned_technician_id',
|
|
'priority',
|
|
'description',
|
|
'status',
|
|
'labor_hours',
|
|
'cost',
|
|
'accounting_journal_mapping_id',
|
|
'images',
|
|
'attachments',
|
|
'signature',
|
|
'completion_report',
|
|
'scheduled_at',
|
|
'completed_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'labor_hours' => 'decimal:2',
|
|
'cost' => 'integer',
|
|
'images' => 'array',
|
|
'attachments' => 'array',
|
|
'signature' => 'array',
|
|
'scheduled_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
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 preventiveSchedule()
|
|
{
|
|
return $this->belongsTo(PreventiveSchedule::class, 'preventive_schedule_id');
|
|
}
|
|
|
|
public function overhaul()
|
|
{
|
|
return $this->belongsTo(Overhaul::class, 'overhaul_id');
|
|
}
|
|
|
|
public function rebuild()
|
|
{
|
|
return $this->belongsTo(RebuildProject::class, 'rebuild_id');
|
|
}
|
|
|
|
public function requester()
|
|
{
|
|
return $this->belongsTo(User::class, 'requester_id');
|
|
}
|
|
|
|
public function assignedTechnician()
|
|
{
|
|
return $this->belongsTo(User::class, 'assigned_technician_id');
|
|
}
|
|
|
|
public function parts()
|
|
{
|
|
return $this->hasMany(WorkOrderPart::class, 'work_order_id');
|
|
}
|
|
}
|