DB物件存取問題 20250606

This commit is contained in:
allen.yan 2025-06-06 18:22:17 +08:00
parent 3307c062ab
commit bb8cdcebe3
3 changed files with 3 additions and 78 deletions

View File

@ -28,30 +28,5 @@ class MachineStatus extends Model
'disk',
'status',
];
public function save(array $options = [])
{
throw new \Exception("MachineStatus is read-only.");
}
public function delete()
{
throw new \Exception("MachineStatus cannot be deleted.");
}
public static function create(array $attributes = [])
{
throw new \Exception("MachineStatus 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.");
});
}
}

View File

@ -28,30 +28,5 @@ class RoomStatusLog extends Model
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.");
});
}
}

View File

@ -38,30 +38,5 @@ class SongLibraryCache extends Model
'song_counts',
'updated_at',
];
public function save(array $options = [])
{
throw new \Exception("SongLibraryCache is read-only.");
}
public function delete()
{
throw new \Exception("SongLibraryCache cannot be deleted.");
}
public static function create(array $attributes = [])
{
throw new \Exception("SongLibraryCache 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.");
});
}
}