<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class NovaCardCreatorPreset extends Model
{
    use HasFactory, SoftDeletes;

    public const TYPE_STYLE = 'style';
    public const TYPE_LAYOUT = 'layout';
    public const TYPE_BACKGROUND = 'background';
    public const TYPE_TYPOGRAPHY = 'typography';
    public const TYPE_STARTER = 'starter';

    public const TYPES = [
        self::TYPE_STYLE,
        self::TYPE_LAYOUT,
        self::TYPE_BACKGROUND,
        self::TYPE_TYPOGRAPHY,
        self::TYPE_STARTER,
    ];

    protected $fillable = [
        'user_id',
        'name',
        'preset_type',
        'config_json',
        'is_default',
    ];

    protected $casts = [
        'config_json' => 'array',
        'is_default' => 'boolean',
    ];

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