<?php

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

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name', 300);
            $table->string('email', 250)->unique();
            $table->string('phone', 15)->nullable()->unique();
            $table->string('photo', 300)->nullable();
            $table->date('birth_date')->nullable();

            $table->enum('gender', ['male', 'female'])->nullable();
            $table->string('city', 300)->nullable();
            $table->string('zip_code', 10)->nullable();
            $table->unsignedBigInteger('country_id')->nullable();
            $table->unsignedBigInteger('state_id')->nullable();
            $table->char('address', 50)->nullable();
            $table->boolean('status')->default(1);

            $table->string('admin_token', 100)->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password', 100);
            $table->enum('role',['super_admin','admin', 'sub_admin', 'user'])->default('sub_admin');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();

            $table->index(['country_id', 'state_id']);
            $table->engine = 'InnoDB';
        });
    }

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