<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
 * Глобальная настройка SaaS (schema v8.7 §3.4 / table system_settings).
 *
 * PRIMARY KEY = key (VARCHAR(100)). Без RLS — общесистемная таблица.
 *
 * @property string $key
 * @property string $value
 * @property string $type
 * @property string|null $description
 * @property Carbon $updated_at
 * @property int|null $updated_by
 *
 * @mixin IdeHelperSystemSetting
 */
class SystemSetting extends Model
{
    protected $primaryKey = 'key';

    public $incrementing = false;

    protected $keyType = 'string';

    /** Schema не имеет created_at — только updated_at. */
    public const CREATED_AT = null;

    protected $fillable = ['key', 'value', 'type', 'description', 'updated_at', 'updated_by'];

    protected function casts(): array
    {
        return [
            'updated_at' => 'datetime',
        ];
    }
}
