74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class InspectionVisit extends Model
|
|
{
|
|
protected $table = 'maintenance_inspection_visits';
|
|
|
|
protected $fillable = [
|
|
'business_id', 'project_id', 'equipment_id', 'production_line_id', 'visit_date', 'health_percentage',
|
|
'working_hours_at_visit', 'visit_type', 'checklist_response_id', 'inspector_id',
|
|
'service_provider_id', 'summary', 'attachments', 'approval_id', 'status',
|
|
];
|
|
|
|
protected $casts = [
|
|
'visit_date' => 'datetime',
|
|
'health_percentage' => 'decimal:2',
|
|
'working_hours_at_visit' => 'decimal:2',
|
|
'attachments' => 'array',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{ }
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(\Modules\Project\Entities\Project::class, 'project_id');
|
|
}
|
|
|
|
public function equipment()
|
|
{
|
|
return $this->belongsTo(Equipment::class, 'equipment_id');
|
|
}
|
|
|
|
public function productionLine()
|
|
{
|
|
return $this->belongsTo(ProductionLine::class, 'production_line_id');
|
|
}
|
|
|
|
public function inspector()
|
|
{
|
|
return $this->belongsTo(User::class, 'inspector_id');
|
|
}
|
|
|
|
public function serviceProvider()
|
|
{
|
|
return $this->belongsTo(ServiceProvider::class, 'service_provider_id');
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(InspectionVisitItem::class, 'inspection_visit_id');
|
|
}
|
|
|
|
public function approval()
|
|
{
|
|
return $this->belongsTo(MaintenanceApproval::class, 'approval_id');
|
|
}
|
|
|
|
public function checklistResponse()
|
|
{
|
|
return $this->belongsTo(ChecklistResponse::class, 'checklist_response_id');
|
|
}
|
|
}
|