<?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->bigIncrements('id');
            $table->string('email')->unique();
            $table->string('password');
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->dateTime('last_login')->nullable()->default(NULL);
            $table->rememberToken();
            $table->timestamps();
        });

        // add billing info table
        Schema::create('billing_addresses', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unique(); // One-to-one relationship with users
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->string('company_name', 100)->nullable();
            $table->string('address')->nullable();
            $table->string('city', 100)->nullable();
            $table->unsignedBigInteger('state_id')->nullable();
            $table->string('zip', 100)->nullable();
            $table->unsignedBigInteger('country_id')->nullable();
            $table->string('phone_number', 100)->nullable();
            $table->timestamps();
        });
    }

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