2023-02-17 06:48:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2023-02-22 15:39:26 +00:00
|
|
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
2023-02-17 06:48:22 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2023-02-17 12:05:47 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2023-02-17 06:48:22 +00:00
|
|
|
|
|
|
|
class Maintenance extends Model
|
|
|
|
{
|
2023-02-22 15:39:26 +00:00
|
|
|
use Cachable;
|
|
|
|
|
2023-02-17 06:48:22 +00:00
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
'content',
|
|
|
|
'module_id',
|
|
|
|
'start_at',
|
|
|
|
'end_at',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'start_at' => 'datetime',
|
|
|
|
'end_at' => 'datetime',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $dates = [
|
|
|
|
'start_at',
|
|
|
|
'end_at',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $with = [
|
|
|
|
'module',
|
|
|
|
];
|
|
|
|
|
2023-02-17 07:19:45 +00:00
|
|
|
// 根据 start_at 排序
|
|
|
|
public function scopeOrderByStartAt($query)
|
|
|
|
{
|
|
|
|
return $query->orderBy('start_at', 'desc');
|
|
|
|
}
|
|
|
|
|
2023-02-17 12:05:47 +00:00
|
|
|
public function module(): BelongsTo
|
2023-02-17 06:48:22 +00:00
|
|
|
{
|
|
|
|
return $this->belongsTo(Module::class);
|
|
|
|
}
|
|
|
|
}
|