<?php

namespace App\Models;

use App\Models\Concerns\HasPublicId;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

final class Company extends Model
{
    use HasPublicId;

    protected $fillable = [
        'public_id', 'legal_name', 'trade_name', 'trn', 'trade_license_number',
        'email', 'phone', 'address', 'country_code', 'base_currency', 'timezone',
        'financial_year_start_month', 'vat_registered', 'vat_registration_date',
        'is_active', 'logo_path', 'stamp_path', 'website', 'bank_details',
        'invoice_terms', 'setup_completed_at',
    ];

    protected function casts(): array
    {
        return [
            'vat_registered' => 'boolean',
            'vat_registration_date' => 'date',
            'is_active' => 'boolean',
            'setup_completed_at' => 'datetime',
        ];
    }

    public function branches(): HasMany { return $this->hasMany(Branch::class); }
    public function users(): HasMany { return $this->hasMany(User::class); }
    public function roles(): HasMany { return $this->hasMany(Role::class); }
    public function fiscalYears(): HasMany { return $this->hasMany(FiscalYear::class); }
    public function eInvoiceConfigurations(): HasMany { return $this->hasMany(EInvoiceConfiguration::class); }
}
