<?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', 255)->nullable();
            $table->string('lname', 255)->nullable();
            $table->integer('national_code')->unique()->nullable();
            $table->json('address')->nullable();
            $table->string('email')->unique()->nullable();
            $table->string('mobile')->unique();
            $table->string('password');
            $table->integer('amount')->nullable()->default(0);
            $table->float('percent')->nullable();
            $table->enum('status', Mehrab\User\Models\User::$status)->default(Mehrab\User\Models\User::ACTIVE);
            $table->timestamp('mobile_verified_at')->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->rememberToken();
            $table->timestamps();

            $table->foreignId('profile_pic_id')
                ->nullable()
                ->constrained('media', 'id')
                ->onDelete('SET NULL');

            $table->foreignId('national_card_pic_id')
                ->nullable()
                ->constrained('media', 'id')
                ->onDelete('SET NULL');

            $table->foreignId('certificate_card_pic_id')
                ->nullable()
                ->constrained('media', 'id')
                ->onDelete('SET NULL');
        });
    }

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