<?php

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

class CreateLeadsTable extends Migration
{
    public function up()
    {
        Schema::create('leads', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('company')->nullable();
            $table->string('phone');
            $table->string('email')->nullable();
            $table->enum('source', ['Website', 'WhatsApp', 'Phone Call', 'Referral', 'Email', 'Walk-in', 'LinkedIn'])->default('Website');
            $table->string('service')->nullable();       // Website Design, SEO Package, etc.
            $table->unsignedBigInteger('budget')->default(0);
            $table->enum('stage', ['New', 'Contacted', 'Positive', 'Follow Up', 'Negotiation', 'Won', 'Lost'])->default('New');
            $table->unsignedBigInteger('assigned_to')->nullable(); // employee id
            $table->enum('priority', ['High', 'Medium', 'Low'])->default('Medium');
            $table->date('last_contact')->nullable();
            $table->timestamps();

            $table->foreign('assigned_to')->references('id')->on('employees')->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::dropIfExists('leads');
    }
}