89 lines
2.2 KiB
PHP
89 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class RebuildProject extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'maintenance_rebuild_projects';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'project_id',
|
|
'production_line_id',
|
|
'scope_type',
|
|
'rebuild_number',
|
|
'title',
|
|
'description',
|
|
'reason',
|
|
'supervisor_id',
|
|
'status',
|
|
'progress_percent',
|
|
'planned_start_date',
|
|
'planned_end_date',
|
|
'actual_start_date',
|
|
'actual_end_date',
|
|
'estimated_cost',
|
|
'actual_cost',
|
|
'shutdown_required',
|
|
'commissioning_required',
|
|
'handover_notes',
|
|
'attachments',
|
|
];
|
|
|
|
protected $casts = [
|
|
'planned_start_date' => 'date',
|
|
'planned_end_date' => 'date',
|
|
'actual_start_date' => 'date',
|
|
'actual_end_date' => 'date',
|
|
'estimated_cost' => 'integer',
|
|
'actual_cost' => 'integer',
|
|
'shutdown_required' => 'boolean',
|
|
'commissioning_required' => 'boolean',
|
|
'attachments' => 'array',
|
|
];
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
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 supervisor()
|
|
{
|
|
return $this->belongsTo(User::class, 'supervisor_id');
|
|
}
|
|
|
|
public function phases()
|
|
{
|
|
return $this->hasMany(RebuildPhase::class, 'rebuild_project_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function equipmentItems()
|
|
{
|
|
return $this->belongsToMany(Equipment::class, 'maintenance_rebuild_equipment', 'rebuild_project_id', 'equipment_id')
|
|
->withPivot(['pre_rebuild_health', 'post_rebuild_health', 'status'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function workOrders()
|
|
{
|
|
return $this->hasMany(WorkOrder::class, 'rebuild_id');
|
|
}
|
|
}
|