<?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)->nullable();
            $table->string('email', 250)->unique();
            $table->string('phone', 14)->nullable()->unique();
            $table->text('register_steps')->nullable();
            $table->string('score', 5)->nullable();
            $table->json('meta');
            $table->string('id_number', '100')->storedAs('setting->"$.id_number"')->index();
            // $table->string('id_number', 100)->virtualAs("JSON_EXTRACT('meta', '$.id_number')")->index();
            $table->string('photo', 300)->nullable();
            $table->string('about_me', 400)->nullable();
            $table->date('birth_date')->nullable();
            $table->string('admin_token', 1000)->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password', 100);
            $table->enum('role',['admin','sub_admin', 'user'])->default('user');

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

            $table->engine = 'InnoDB';
        });
    }

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