<?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->integer('parent_id')->nullable()->index();
            $table->integer('role_id')->nullable()->index();
            $table->string('name', 100)->nullable();
            $table->string('last_name', 100)->nullable();
            $table->string('email', 100)->unique()->nullable();
            $table->string('phone', 50)->nullable();
            $table->string('reg_number', 100)->nullable();
            $table->string('logo', 200)->nullable();
            $table->string('rera_licence', 200)->nullable();
            $table->string('broker_card', 200)->nullable();
            $table->string('owner_id', 200)->nullable();
            $table->string('emirates_id_front', 200)->nullable();
            $table->string('emirates_id_back', 200)->nullable();
            $table->string('copy_of_passport', 200)->nullable();
            $table->string('copy_of_visa', 200)->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('forgot_password_token', 100)->nullable();
            $table->string('password', 500);
            $table->string('roles', 100)->nullable();
            $table->string('type_of_agent', 20)->nullable();
            $table->tinyInteger('type')->nullable()->comment('1 for admin, 2 for agency, 3 for agent');
            $table->tinyInteger('device_type')->nullable();
            $table->string('fcm_token', 50)->nullable();
            $table->tinyInteger('status')->default(2)->comment('1 for active, 2 for inactive');
            $table->dateTime('last_login')->nullable();
            $table->integer('added_by')->nullable()->index();
            $table->integer('updated_by')->nullable()->index();
            $table->integer('deleted_by')->nullable()->index();
            $table->timestamps();
            $table->rememberToken();
            $table->softDeletes();
        });
    }

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