LAR_Maintenance/app/Models/Maintenance.php

42 lines
835 B
PHP
Raw Normal View History

2024-07-30 10:44:58 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Maintenance extends Model
{
use HasFactory;
2024-07-30 18:13:21 +02:00
protected $fillable = [
'name',
'description',
'schedule',
'guestor_id',
'blocking_maintenance_id',
'duration',
'blocking_maintenance_offset',
2024-07-30 18:13:21 +02:00
];
2024-07-31 17:04:33 +02:00
2024-08-06 11:02:45 +02:00
public function hosts()
2024-07-31 17:04:33 +02:00
{
2024-08-06 11:02:45 +02:00
return $this->belongsToMany(Host::class, "maintenance_host", "maintenance_id", "host_id" );
2024-07-31 17:04:33 +02:00
}
2024-07-31 18:45:14 +02:00
2024-08-06 11:02:45 +02:00
public function history()
2024-07-31 18:45:14 +02:00
{
2024-08-06 11:02:45 +02:00
return $this->hasMany(MaintenanceHistory::class);
2024-07-31 18:45:14 +02:00
}
2024-08-06 08:31:51 +02:00
public function tasks()
{
return $this->hasMany(MaintenanceTask::class,);
}
public function guestor()
{
return $this->BelongsTo(User::class, 'guestor_id');
}
2024-07-30 10:44:58 +02:00
}