<?php

namespace App\Domains\Tenant\Models;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

#[Fillable([
    'website_type_code',
    'codigo',
    'nombre',
    'descripcion',
    'is_required',
    'config_schema',
])]
class WebsiteTypeExtra extends Model
{
    use HasFactory;

    protected $table = 'website_type_extras';

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

    /**
     * @return BelongsTo<WebsiteType, $this>
     */
    public function websiteType(): BelongsTo
    {
        return $this->belongsTo(WebsiteType::class, 'website_type_code', 'codigo');
    }

    /**
     * @return HasMany<WebsiteExtra, $this>
     */
    public function websiteExtras(): HasMany
    {
        return $this->hasMany(WebsiteExtra::class, 'website_type_extra_id');
    }
}
