<?php

declare(strict_types=1);

namespace Maestro\Core\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Singleton row: app-wide theme (PrimeVue shell) and branding asset paths.
 *
 * @property array<string, mixed>|null $theme
 * @property string|null $logo_sidebar_path
 * @property string|null $logo_header_path
 * @property string|null $logo_compact_path
 * @property string|null $favicon_path
 * @property string|null $login_hero_path
 * @property list<string>|null $offer_document_background_paths
 * @property array{enabled?: bool, mode?: string}|null $public_page
 * @property array{providers?: array<string, bool|null>}|null $login
 */
class MaestroAppSetting extends Model
{
    protected $table = 'maestro_app_settings';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'theme',
        'logo_sidebar_path',
        'logo_header_path',
        'logo_compact_path',
        'favicon_path',
        'login_hero_path',
        'offer_document_background_paths',
        'public_page',
        'login',
    ];

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

    public static function instance(): self
    {
        /** @var self $row */
        $row = static::query()->firstOrCreate([], []);

        return $row;
    }
}
