<?php

namespace Maestro\Core\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Per-user table state (column order, visible columns, filters, etc.) keyed by table_key.
 */
class UserTableState extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var list<string>
     */
    protected $fillable = [
        'user_id',
        'table_key',
        'state',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'state' => 'array',
    ];

    /**
     * Get the user that owns the table state.
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
