<?php

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

class CreateSuppliersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('suppliers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->string('company_name');
            $table->boolean('membership')->default(false);
            $table->string('cover_photo')->nullable();
            $table->string('tags')->nullable();
            $table->string('description')->nullable();
            $table->string('CURP', 18)->unique()->nullable();
            $table->string('RFC', 14)->unique()->nullable();
            $table->string('regimen')->nullable();
            $table->string('clabe')->unique()->nullable();
            $table->unsignedBigInteger('bank_id')->nullable();
            $table->float('minimun_fee')->nullable();
            $table->unsignedBigInteger('IVA_id')->nullable();
            $table->unsignedBigInteger('ISR_id')->nullable();
            $table->unsignedBigInteger('finished_jobs')->default(1);
            $table->unsignedBigInteger('total_score')->default(3);
            $table->string('address')->nullable();
            $table->point('location')->nullable();
            $table->boolean('en')->default(false);
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
            $table->foreign('bank_id')->references('id')->on('banks')->onDelete('set null');
            $table->foreign('IVA_id')->references('id')->on('i_chamba_parameters')->onDelete('set null');
            $table->foreign('ISR_id')->references('id')->on('i_chamba_parameters')->onDelete('set null');
        });
    }

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