<?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', 100)->unique();
            $table->string('phone', 15)->nullable()->unique();
            $table->unsignedBigInteger('city_id')->nullable()->index();
            $table->json('device_token')->nullable();
            $table->string('api_token', 50)->nullable();

            $table->char('verify_code', 4)->nullable()->comment('code for reset psw or login');
            $table->string('attempt_send_code', 2)->nullable()->comment('The number of times the code is sent per day');
            $table->date('last_attempt_date')->nullable()->comment('Last sent date');
            $table->string('code_verify_attempt', 2)->nullable()->comment('Code verification attempts');

            $table->string('photo', 300)->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->engine = 'InnoDB';
        });
    }

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