LAR_Maintenance/app/Models/MaintenanceHistory.php

45 lines
903 B
PHP
Raw Normal View History

2024-07-30 08:44:58 +00:00
<?php
namespace App\Models;
2024-08-16 16:20:45 +00:00
use App\Observers\MaintenanceHistoryObserver;
2024-07-30 08:44:58 +00:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MaintenanceHistory extends Model
{
use HasFactory;
2024-07-31 15:04:33 +00:00
protected $fillable = [
'maintenance_id',
'start_at',
'finished_at',
'guestor_id',
2024-07-31 15:04:33 +00:00
];
2024-08-16 21:37:42 +00:00
protected $casts = [
'start_at' => 'datetime',
'finished_at' => 'datetime',
];
2024-08-16 16:20:45 +00:00
protected static function booted()
{
MaintenanceHistory::observe(MaintenanceHistoryObserver::class);
}
2024-07-31 15:04:33 +00:00
public function maintenance()
{
return $this->BelongsTo(Maintenance::class);
}
2024-08-06 09:02:45 +00:00
public function historyHosts()
{
return $this->hasMany(MaintenanceHostHistory::class);
}
public function guestor()
{
return $this->BelongsTo(User::class, 'guestor_id');
}
2024-07-30 08:44:58 +00:00
}