'datetime', 'ended_at' => 'datetime', ]; // 狀態常數 public const STATUS_ACTIVE = 'active'; public const STATUS_CLOSED = 'closed'; public const STATUS_FORCE_CLOSED = 'force_closed'; public const STATUS_FIRE_CLOSED = 'fire_closed'; // 模式常數 public const MODE_NORMAL = 'normal'; public const MODE_VIP = 'vip'; public const MODE_TEST = 'test'; public function scopeValidToken($query, ?string $token) { return $query->with('room') ->where('api_token', $token) ->whereIn('status', ['active', 'maintain']); } public function refreshValid(): ?self { return self::validToken($this->api_token) ->where('id', $this->id) ->first(); } public function room() { return $this->belongsTo(Room::class); } }