<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('leads', function (Blueprint $table) {
            $table->id();
            $table->foreignId('company_id')->constrained('companies')->cascadeOnDelete();
            $table->string('name');
            $table->string('email')->nullable()->index();
            $table->string('country_code')->nullable();
            $table->string('phone')->unique()->index();
            $table->string('source')->nullable();
            $table->string('designation')->nullable();
            $table->enum('priority', ['low', 'high'])->default('low');
            $table->enum('status', ['raw', 'verified', 'client'])->default('raw');
            $table->unsignedTinyInteger('is_interest')->default(1);
            $table->text('interest_remark')->nullable();
            $table->unsignedTinyInteger('is_call_back')->default(0);
            $table->unsignedTinyInteger('is_primary')->default(1);
            $table->dateTime('cnvt_to_verified_at')->nullable();
            $table->dateTime('cnvt_to_client_at')->nullable();
            $table->foreignId('created_by')->constrained('users')->cascadeOnDelete();
            $table->foreignId('assigned_to')->nullable()->constrained('users')->cascadeOnDelete();
            $table->unsignedTinyInteger('is_deleted')->default(0);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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