<?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('sponsors', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->string('fiscal_code', 16)->nullable();
            $table->string('vat', 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('email')->nullable();

            $table->integer('enabled')->default(1);




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

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