<?php

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

class CreateRequestForQuotationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('request_for_quotations', function (Blueprint $table) {
            $table->id();
            $table->string('reference_no')->nullable();
            $table->date('bidding_start_date')->nullable();
            $table->date('bidding_end_date')->nullable();
            $table->date('delivery_date')->nullable();
            $table->bigInteger('created_by_user_id')->nullable()->unsigned();
            $table->foreign('created_by_user_id')->references('id')->on('users');
            $table->bigInteger('reviewed_by_user_id')->nullable()->unsigned();
            $table->foreign('reviewed_by_user_id')->references('id')->on('users');
            $table->string('file')->nullable();
            $table->string('overall_comment')->nullable();
            $table->bigInteger('delivery_address_id')->nullable()->unsigned();
            $table->foreign('delivery_address_id')->references('id')->on('client_address');
            $table->string('attachment_file')->nullable();
            $table->bigInteger('client_id')->nullable()->unsigned();
            $table->foreign('client_id')->references('id')->on('clients');
            $table->string('name')->nullable();
            $table->bigInteger('tnc_id')->nullable()->unsigned();
            $table->foreign('tnc_id')->references('id')->on('terms_and_conditaions');
            $table->boolean('is_accepted')->default(0);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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