2025-05-28 09:24:03 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class RoomStatusLog extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
public $timestamps = true;
|
|
|
|
|
|
|
|
protected $fillable =
|
|
|
|
[
|
|
|
|
'room_id',
|
|
|
|
'user_id',
|
|
|
|
'status',
|
|
|
|
'message',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'status' => \App\Enums\RoomStatus::class,
|
|
|
|
];
|
2025-06-06 18:11:22 +08:00
|
|
|
public function user(){
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
}
|
2025-05-28 09:24:03 +08:00
|
|
|
public function room() {
|
|
|
|
return $this->belongsTo(Room::class);
|
|
|
|
}
|
2025-06-06 18:11:22 +08:00
|
|
|
public function save(array $options = [])
|
|
|
|
{
|
|
|
|
throw new \Exception("RoomStatusLog is read-only.");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
throw new \Exception("RoomStatusLog cannot be deleted.");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function create(array $attributes = [])
|
|
|
|
{
|
|
|
|
throw new \Exception("RoomStatusLog is read-only.");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function booted()
|
|
|
|
{
|
|
|
|
// 防止 mass update/delete
|
|
|
|
static::updating(function () {
|
|
|
|
throw new \Exception("Updating is not allowed.");
|
|
|
|
});
|
|
|
|
|
|
|
|
static::deleting(function () {
|
|
|
|
throw new \Exception("Deleting is not allowed.");
|
|
|
|
});
|
|
|
|
}
|
2025-05-28 09:24:03 +08:00
|
|
|
}
|