<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class   CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('password');
            $table->string('name');
            $table->string('surname');
            $table->string('PESEL',11);
            $table->string('phoneNumber', 20);
            $table->string('email', 100)->unique();
            $table->integer('fire_station_id')->unsigned()->nullable();
            $table->foreign('fire_station_id')->references('id')->on('fire_stations')->onDelete('cascade');
            $table->integer('unit_function_id')->unsigned()->nullable();
            $table->foreign('unit_function_id')->references('id')->on('unit_functions')->onDelete('set null');
            $table->integer('rank_id')->unsigned()->nullable();
            $table->foreign('rank_id')->references('id')->on('ranks')->onDelete('set null');
            $table->string('number')->nullable()->default(null);
            $table->string('second_name')->nullable()->default(null);
            $table->string('fathers_name')->nullable()->default(null);
            $table->string('mothers_name')->nullable()->default(null);
            $table->string('address')->nullable()->default(null);
            $table->string('apartment')->nullable()->default(null); //nr domu
            $table->string('place_of_birth')->nullable()->default(null);
            $table->string('drivers_license')->nullable()->default(null);
            $table->date('joining_osp_date')->nullable()->default(null);
            $table->string('id_series', 3)->nullable()->default(null);
            $table->string('id_number', 6)->nullable()->default(null); //nr dowodu osobistego
            $table->date('id_valid_until')->nullable()->default(null);
            $table->string('identity_card_number')->nullable()->default(null); //nr legitymacji strażackiej
            $table->string('home_phone_number', 20)->nullable()->default(null);
            $table->string('education')->nullable()->default(null);
            $table->string('profession')->nullable()->default(null);
            $table->integer('status_id')->default(0);    //aktywny/zawieszony
            $table->integer('creator_id')->nullable()->default(null);
            $table->integer('editor_id')->nullable()->default(null);
            $table->boolean('confirmed')->default(0);
            $table->string('confirmation_code')->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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