<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class RoomSession extends Model
{
    use HasFactory;

    protected $fillable = [
        'room_id',
        'started_at',
        'ended_at',
        'status',
        'mode',
        'close_reason',
        'api_token',
    ];

    protected $casts = [
        'started_at' => '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 room()
    {
        return $this->belongsTo(Room::class);
    }
}
