<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CompanyProfile extends Model
{
    use HasFactory;

    protected $fillable = [
        'company_name_en',
        'company_name_ar',
        'trade_name',
        'legal_name',
        'vat_number',
        'cr_number',
        'building_number',
        'street_name_en',
        'street_name_ar',
        'district_en',
        'district_ar',
        'city_en',
        'city_ar',
        'postal_code',
        'additional_number',
        'country',
        'country_code',
        'phone',
        'mobile',
        'email',
        'website',
        'logo_path',
        'invoice_logo_path',
        'company_stamp_path',
        'authorized_signature_path',
        'bank_name',
        'bank_account_name',
        'account_number',
        'iban',
        'default_currency',
        'currency_display',
        'vat_registered',
        'default_vat_rate',
        'tax_invoice_footer_en',
        'tax_invoice_footer_ar',
        'terms_conditions_en',
        'terms_conditions_ar',
        'received_by_label',
    ];

    protected $casts = [
        'vat_registered' => 'boolean',
        'default_vat_rate' => 'decimal:2',
    ];

    public static function getProfile()
    {
        return static::first() ?? static::create([
            'company_name_en' => 'MUTLAQ SALEH SATI',
            'company_name_ar' => 'مطلق صالح ساطي',
            'vat_number' => '302176698800003',
            'cr_number' => '1010123456',
            'building_number' => '1234',
            'street_name_en' => 'King Fahd Road',
            'street_name_ar' => 'طريق الملك فهد',
            'district_en' => 'Olaya',
            'district_ar' => 'العليا',
            'city_en' => 'Riyadh',
            'city_ar' => 'الرياض',
            'postal_code' => '12211',
            'additional_number' => '5678',
            'country' => 'Saudi Arabia',
            'country_code' => '+966',
            'phone' => '+966 11 234 5678',
            'email' => 'info@mutlaqsati.sa',
            'default_currency' => 'SAR',
            'currency_display' => 'SAR',
            'vat_registered' => true,
            'default_vat_rate' => 15.00,
            'tax_invoice_footer_en' => 'Thank you for your business.',
            'tax_invoice_footer_ar' => 'شكراً لتعاملكم معنا.',
            'terms_conditions_en' => 'Goods once sold are non-refundable after 7 days.',
            'terms_conditions_ar' => 'البضاعة المباعة لا تُرد بعد 7 أيام.',
            'received_by_label' => 'Received By / المستلم',
        ]);
    }
}
