<?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('first_name', 100);
            $table->string('last_name', 100);
            $table->string('phone', 15)->nullable();
            $table->string('email', 100)->unique();
            $table->enum('document_type', ['1', '2', '3','4'])->default('1');
            $table->string('document',15)->unique();
            $table->string('document_expedition',50)->nullable();
            $table->enum('gender_user',['Masculino', 'Femenino']);
            $table->enum('status', ['ACTIVO', 'INACTIVO'])->default('ACTIVO');
            $table->enum('civil_status',['1','2','3','4','5']);
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->boolean('weak_password')->default(true);
            $table->string('nationality',50)->nullable();
            $table->date('birth_date')->nullable();
            $table->string('birth_place',100)->nullable();
            $table->string('address',100)->nullable();
            $table->string('state_residence',2)->default('73')->nullable();
            $table->string('city_residence',5)->default('73001')->nullable();
            $table->foreign('state_residence')
                    ->references('code')->on('states')
                    ->onDelete('set null');
            $table->foreign('city_residence')
                    ->references('code')->on('cities')
                    ->onDelete('set null');
            $table->bigInteger('eps_id')->unsigned()->nullable();
            $table->foreign('eps_id')->references('id')->on('public_health_entities')
                ->onDelete('set null')
                ->onUpdate('set null');
            $table->string('title_position',100)->nullable();
            $table->string('professional_license',100)->nullable();
            $table->text('professional_profile')->nullable();
            $table->string('social_linkedin',100)->nullable();
            $table->string('social_facebook',100)->nullable();
            $table->string('social_instagram',100)->nullable();
            $table->string('social_twitter',100)->nullable();
            $table->string('image', 100)->nullable();
            $table->string('signature')->nullable();
            $table->integer('notification')->default(0);
            $table->timestamp('last_login_at')->nullable();
            $table->string('last_login_ip')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });
    }

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