<?php

namespace App\Models\Order\Loan;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class LoanOrder extends Model
{
    use HasFactory;
    use SoftDeletes;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'unique_id',
        'loan_type',
        'region',
        'branch_id',
        'customer_name',
        'customer_surname',
        'customer_patronic_name',
        'passport_address',
        'real_address',
        'passport_serie',
        'passport_id',
        'passport_given_at',
        'passport_given_by',
        'born_place',
        'born_at',
        'email',
        'phone',
        'phone_additional',
        'phone_home',
        'work_region',
        'work_province',
        'work_company',
        'work_company_accountant_number',
        'work_started_at',
        'work_salary',
        'work_position',
        'education',
        'marriage_status',
        'passport_one',
        'passport_two',
        'passport_three',
        'passport_four',
        'filled_by',
        'user_id',
        'status',
        'status_reason',
        'notes',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'born_at' => 'date',
        'passport_given_at' => 'date',
        'work_started_at' => 'date',
    ];

    /**
     * Loan type
     */
    public function loanType(): BelongsTo
    {
        return $this->belongsTo(LoanType::class);
    }
}
