<?php

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

class CreateLeadTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('lead', function (Blueprint $table) {
            $table->id();
            $table->text('description')->nullable();
            $table->enum('lead_status',['pending','on_hold','converted','cancelled'])->nullable();
            $table->bigInteger('assign_to_user_id')->nullable()->unsigned();
            $table->foreign('assign_to_user_id')->references('id')->on('users');
            $table->bigInteger('created_by_user_id')->nullable()->unsigned();
            $table->foreign('created_by_user_id')->references('id')->on('users');
            $table->string('reference_no')->nullable();
            $table->bigInteger('client_id')->nullable()->unsigned();
            $table->foreign('client_id')->references('id')->on('clients');
            $table->dateTime('follow_up_date')->nullable();
            $table->dateTime('alert_date')->nullable();
            $table->enum('lead_source',['direct','friend','relative','dealer','employee','print_media','online_media','referral','any_other'])->nullable();
            $table->boolean('is_converted_enquiry')->nullable()->default(0);
            $table->boolean('is_converted_quotation')->nullable()->default(0);
            $table->timestamps();
        });
    }

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