<?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('card_pin_orders', function (Blueprint $table) {
            $table->id();
            $table->string('unique_id')->nullable()->unique();
            $table->foreignId('user_id')->constrained('users')->cascadeOnDelete();

            $table->foreignId('card_type_id')->constrained('card_types')->restrictOnDelete();
            $table->string('card_number');

            // Region & Branch
            $table->string('region', 2);
            $table->foreignId('branch_id')->constrained('branches')->restrictOnDelete();

            // Customer name,surname,patronic name
            $table->string('customer_name')->index();
            $table->string('customer_surname')->index();
            $table->string('customer_patronic_name')->nullable();

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

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

            $table->text('passport_one')->nullable();
            $table->text('passport_two')->nullable();
            $table->text('passport_three')->nullable();
            $table->text('passport_four')->nullable();

            $table->string('status')->nullable();
            $table->string('notes')->nullable();
            $table->timestamps();
        });
    }

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