LAR_Maintenance/app/Models/MaintenanceHistory.php

45 lines
903 B
PHP

<?php
namespace App\Models;
use App\Observers\MaintenanceHistoryObserver;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MaintenanceHistory extends Model
{
use HasFactory;
protected $fillable = [
'maintenance_id',
'start_at',
'finished_at',
'guestor_id',
];
protected $casts = [
'start_at' => 'datetime',
'finished_at' => 'datetime',
];
protected static function booted()
{
MaintenanceHistory::observe(MaintenanceHistoryObserver::class);
}
public function maintenance()
{
return $this->BelongsTo(Maintenance::class);
}
public function historyHosts()
{
return $this->hasMany(MaintenanceHostHistory::class);
}
public function guestor()
{
return $this->BelongsTo(User::class, 'guestor_id');
}
}