<?php

namespace App\Domains\Tenant\Models;

use App\Domains\Attachable\Models\Attachment;
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([
    'codigo',
    'nombre',
    'dominio',
    'scanner_domain',
    'site_title',
    'primary_color',
    'secondary_color',
    'danger_color',
    'success_color',
    'warning_color',
    'body_color',
    'darker_body_color',
    'surface_color',
    'background_color',
    'border_color',
    'login_header_footer_color',
    'site_logo',
    'footer_logo',
    'favicon_id',
])]
class WebsiteType extends Model
{
    use HasFactory;

    protected $table = 'website_type';

    /**
     * @return BelongsTo<Attachment, $this>
     */
    public function siteLogo(): BelongsTo
    {
        return $this->belongsTo(Attachment::class, 'site_logo');
    }

    /**
     * @return BelongsTo<Attachment, $this>
     */
    public function footerLogo(): BelongsTo
    {
        return $this->belongsTo(Attachment::class, 'footer_logo');
    }

    /**
     * @return BelongsTo<Attachment, $this>
     */
    public function favicon(): BelongsTo
    {
        return $this->belongsTo(Attachment::class, 'favicon_id');
    }

    /**
     * @return HasMany<WebsiteTypeExtra, $this>
     */
    public function extras(): HasMany
    {
        return $this->hasMany(WebsiteTypeExtra::class, 'website_type_code', 'codigo');
    }

    /**
     * @return HasMany<Tenant, $this>
     */
    public function tenants(): HasMany
    {
        return $this->hasMany(Tenant::class, 'website_type_code', 'codigo');
    }
}
