KTVCentral/app/Models/RoomStatusLog.php

58 lines
1.2 KiB
PHP
Raw Normal View History

<?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,
];
public function user(){
return $this->belongsTo(User::class);
}
public function room() {
return $this->belongsTo(Room::class);
}
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.");
});
}
}