<?php

declare(strict_types=1);

namespace Maestro\Core\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Maestro\Core\Support\AuthUserResolver;

/**
 * @property int $id
 * @property int $user_id
 * @property string $table_key
 * @property array<string, mixed> $state
 */
class UserTableState extends Model
{
    /**
     * @var list<string>
     */
    protected $fillable = [
        'user_id',
        'table_key',
        'state',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'state' => 'array',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(AuthUserResolver::eloquentModelClass());
    }
}
