<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('loan_paid_off_letters', function (Blueprint $table) {
            $table->id();

            $table->string('unique_id')->nullable()->unique();
            $table->string('region', 2)->index();
            $table->foreignId('branch_id')->constrained('branches')->restrictOnDelete();

            $table->string('customer_name')->index();
            $table->string('customer_surname')->index();
            $table->string('customer_patronic_name')->nullable();
            $table->date('born_at')->nullable();

            $table->string('phone')->nullable()->index();

            $table->string('passport_serie')->index();
            $table->string('passport_id')->index();

            $table->string('status')->nullable()->index();

            $table->text('notes')->nullable();

            $table->foreignId('user_id')->constrained('users')->restrictOnDelete();

            $table->string('loan_contract_number')->nullable();
            $table->string('loan_contract_date')->nullable();
            $table->string('loan_amount')->nullable();
            $table->string('loan_reason')->nullable();

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        //
    }
};
