KTVCentral/app/Models/MachineStatus.php

58 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @OA\Schema(
* schema="MachineStatus",
* type="object",
* @OA\Property(property="branch_name", type="string", example="測試"),
* @OA\Property(property="hostname", type="string", example="PC101"),
* @OA\Property(property="ip", type="string", example="192.168.XX.XX"),
* @OA\Property(property="cpu", type="numeric", example="0.00"),
* @OA\Property(property="memory", type="numeric", example="25603"),
* @OA\Property(property="disk", type="numeric", example="158266.49"),
* @OA\Property(property="status", type="string", example="online,error"),
* )
*/
class MachineStatus extends Model
{
protected $fillable = [
'branch_name',
'hostname',
'ip',
'cpu',
'memory',
'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.");
});
}
}