<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('backend_users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('first_name', 50);
            $table->string('last_name', 50);
            $table->string('name', 100);
            $table->string('email', 100);
            $table->string('username', 20);
            $table->string('password', 255);
            $table->rememberToken();
            $table->string('location', 100)->nullable();
            $table->string('contact_1', 40)->nullable();
            $table->string('contact_2', 40)->nullable();
            $table->string('role', 40)->nullable();
            $table->unsignedBigInteger('type_id');
            $table->nullableTimestamps();
            $table->softDeletes();

            $table->foreign('type_id')
                ->references('id')->on('backend_user_types')
                ->onDelete('RESTRICT')->onUpdate('RESTRICT');

            $table->unique('email');
            $table->unique('username');

        });
    }

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