75 lines
1.6 KiB
PHP
75 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class FailureReport extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'maintenance_failure_reports';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'equipment_id',
|
|
'project_id',
|
|
'production_line_id',
|
|
'work_order_id',
|
|
'failure_type',
|
|
'root_cause',
|
|
'corrective_action',
|
|
'preventive_action',
|
|
'downtime_hours',
|
|
'repair_hours',
|
|
'lost_production',
|
|
'cost',
|
|
'reported_by',
|
|
'reported_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'downtime_hours' => 'decimal:2',
|
|
'repair_hours' => 'decimal:2',
|
|
'lost_production' => 'decimal:2',
|
|
'cost' => 'integer',
|
|
'reported_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 workOrder()
|
|
{
|
|
return $this->belongsTo(WorkOrder::class, 'work_order_id');
|
|
}
|
|
|
|
public function reporter()
|
|
{
|
|
return $this->belongsTo(User::class, 'reported_by');
|
|
}
|
|
}
|