<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('members', function (Blueprint $table) {
            $table->id();
            $table->string('first_name');
            $table->string('last_name');
            $table->string('status');
            $table->unsignedBigInteger('birth_city_id')->nullable();
            $table->foreign('birth_city_id')->nullable()->references('id')->on('cities')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('birth_province_id')->nullable();
            $table->foreign('birth_province_id')->nullable()->references('id')->on('provinces')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('birth_nation_id')->nullable();
            $table->foreign('birth_nation_id')->nullable()->references('id')->on('nations')->onUpdate('cascade')->onDelete('cascade');
            $table->date('birth_date')->nullable();
            $table->string('gender', 1)->nullable();
            $table->string('fiscal_code', 16)->nullable();
            $table->string('address')->nullable();
            $table->string('zip_code', 5)->nullable();
            $table->unsignedBigInteger('nation_id')->nullable();
            $table->foreign('nation_id')->nullable()->references('id')->on('nations')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('province_id')->nullable();
            $table->foreign('province_id')->nullable()->references('id')->on('provinces')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('city_id')->nullable();
            $table->foreign('city_id')->nullable()->references('id')->on('cities')->onUpdate('cascade')->onDelete('cascade');
            $table->string('phone')->nullable();
            $table->string('phone2')->nullable();
            $table->string('phone3')->nullable();
            $table->string('email')->nullable();
            $table->string('image')->nullable();
            $table->string('father_name')->nullable();
            $table->string('father_mail')->nullable();
            $table->string('father_phone')->nullable();
            $table->string('father_fiscal_code')->nullable();
            $table->string('mother_name')->nullable();
            $table->string('mother_mail')->nullable();
            $table->string('mother_phone')->nullable();
            $table->string('mother_fiscal_code')->nullable();
            $table->string('birth_place')->nullable();
            $table->integer('enabled')->default(1);

            $table->string('document_type')->nullable();
            $table->string('document_number')->nullable();
            $table->string('document_from')->nullable();
            $table->string('document_expire_date')->nullable();
            $table->string('document_files')->nullable();

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

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('members');
    }
};
