KTVCentral/app/Models/Room.php
allen.yan 7c8c3fe69b DB 滙入
User 介面 只能看資料不能做修改
Role 介面移除
Branch介面 只能看資料不能做修改
Room 介面 可操控 包廂開關台
Sqgger API 可操控API
Room 有操控異動記錄
machine_statuses 需做資料留存需留7 天
20250528
2025-05-28 09:24:03 +08:00

83 lines
2.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Traits\LogsModelActivity;
/**
* @OA\Schema(
* schema="Room",
* type="object",
* @OA\Property(property="id", type="integer", example=16),
* @OA\Property(property="floor", type="integer", example="1"),
* @OA\Property(property="type", ref="#/components/schemas/RoomType"),
* @OA\Property(property="name", type="string", example="pc102"),
* @OA\Property(property="internal_ip", type="string", example="192.168.11.7"),
* @OA\Property(property="port", type="int", example="9000"),
* @OA\Property(property="status", ref="#/components/schemas/RoomStatus"),
* @OA\Property(property="started_at", type="string", format="date-time", example="2025-05-11T16:00:00.000000Z"),
* @OA\Property(property="ended_at", type="string", format="date-time", example=null),
* )
*/
class Room extends Model
{
/** @use HasFactory<\Database\Factories\ArtistFactory> */
use HasFactory, LogsModelActivity;
protected $fillable = [
'floor',
'type',
'name',
'internal_ip',
'port',
'is_online',
'status',
'started_at',
'ended_at',
];
protected $hidden = [
'internal_ip',
'port',
];
protected $casts = [
'floor' => 'int',
'type' => \App\Enums\RoomType::class,
'name' => 'string',
'internal_ip' =>'string',
'port' => 'int',
'is_online' => 'boolean',
'status' => \App\Enums\RoomStatus::class,
'started_at' => 'datetime',
'ended_at' => 'datetime',
];
public function str_started_at(){
$str ="Not Set";
if($this->started_at !=null){
$str = $this->started_at;
}
return $str;
}
public function str_ended_at(){
$str ="Not Set";
if($this->ended_at !=null){
$str = $this->ended_at;
}
return $str;
}
public function branch() {
return $this->belongsTo(Branch::class);
}
public function statusLogs() {
return $this->hasMany(RoomStatusLog::class);
}
}