<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
 * Реквизиты тенанта (G1/SP2). 1:1 с tenants. RLS по tenant_id.
 *
 * Свойства аннотированы явно: `ide-helper:models` пропускает эту модель при
 * интроспекции (стаб IdeHelperTenantRequisites не генерируется), поэтому
 *
 * @property-аннотации заданы вручную по db/schema.sql (tenant_requisites).
 *
 * @property int $id
 * @property int $tenant_id
 * @property string $subject_type
 * @property string $contact_name
 * @property string $contact_phone
 * @property string|null $inn
 * @property string|null $legal_name
 * @property string|null $kpp
 * @property string|null $ogrn
 * @property string|null $legal_address
 * @property string|null $bank_name
 * @property string|null $bank_bik
 * @property string|null $bank_account
 * @property string|null $corr_account
 * @property array<string, mixed>|null $dadata_raw
 * @property Carbon|null $dadata_synced_at
 * @property Carbon|null $requisites_completed_at
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 */
class TenantRequisites extends Model
{
    protected $table = 'tenant_requisites';

    protected $fillable = [
        'tenant_id', 'subject_type', 'contact_name', 'contact_phone',
        'inn', 'legal_name', 'kpp', 'ogrn', 'legal_address',
        'bank_name', 'bank_bik', 'bank_account', 'corr_account',
        'dadata_raw', 'dadata_synced_at', 'requisites_completed_at',
    ];

    protected function casts(): array
    {
        return [
            'dadata_raw' => 'array',
            'dadata_synced_at' => 'datetime',
            'requisites_completed_at' => 'datetime',
            'created_at' => 'datetime',
            'updated_at' => 'datetime',
        ];
    }
}
