<?php

namespace App\Models;

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

#[Fillable([
    'name',
    'slug',
    'logo_path',
    'widget_public_key',
    'widget_enabled',
    'widget_allowed_origins',
    'widget_title',
    'widget_subtitle',
    'widget_status_message',
    'widget_greeting',
    'widget_launcher_label',
    'widget_accent_color',
    'widget_logo_url',
    'widget_quick_replies',
    'widget_position',
    'widget_size',
    'widget_powered_by_branding',
    'widget_header_style',
    'widget_header_color',
    'widget_header_gradient_to',
    'widget_header_text_color',
    'widget_status_background_color',
    'widget_body_background_color',
    'widget_date_pill_background_color',
    'widget_date_pill_text_color',
    'widget_bot_message_background_color',
    'widget_bot_message_text_color',
    'widget_quick_reply_background_color',
    'widget_quick_reply_text_color',
    'widget_composer_background_color',
    'widget_input_background_color',
    'widget_send_button_color',
    'widget_show_clear_history',
    'widget_show_close_button',
])]
class Organization extends Model
{
    /** @use HasFactory<OrganizationFactory> */
    use HasFactory;

    /**
     * @return HasMany<Membership, $this>
     */
    public function memberships(): HasMany
    {
        return $this->hasMany(Membership::class);
    }

    /**
     * @return HasMany<Contact, $this>
     */
    public function contacts(): HasMany
    {
        return $this->hasMany(Contact::class);
    }

    /**
     * @return HasMany<Conversation, $this>
     */
    public function conversations(): HasMany
    {
        return $this->hasMany(Conversation::class);
    }

    /**
     * @return HasMany<Intent, $this>
     */
    public function intents(): HasMany
    {
        return $this->hasMany(Intent::class);
    }

    /**
     * @return HasMany<ResponseTemplate, $this>
     */
    public function responseTemplates(): HasMany
    {
        return $this->hasMany(ResponseTemplate::class);
    }

    /**
     * @return HasMany<IntentPhrase, $this>
     */
    public function intentPhrases(): HasMany
    {
        return $this->hasMany(IntentPhrase::class);
    }

    /**
     * @return HasMany<UnknownQuestion, $this>
     */
    public function unknownQuestions(): HasMany
    {
        return $this->hasMany(UnknownQuestion::class);
    }

    /**
     * @return HasMany<CallbackRequest, $this>
     */
    public function callbackRequests(): HasMany
    {
        return $this->hasMany(CallbackRequest::class);
    }

    /**
     * @return HasMany<ChannelIntegration, $this>
     */
    public function channelIntegrations(): HasMany
    {
        return $this->hasMany(ChannelIntegration::class);
    }

    /**
     * @return HasMany<TypoCorrection, $this>
     */
    public function typoCorrections(): HasMany
    {
        return $this->hasMany(TypoCorrection::class);
    }

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'widget_enabled' => 'boolean',
            'widget_powered_by_branding' => 'boolean',
        ];
    }
}
