<?php

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


return new class extends Migration
{
    public function up(): void
    {
        Schema::create('leads', function (Blueprint $table) {
            $table->id();
            $table->string('source')->default('chatbot');
            $table->string('category_slug')->nullable();
            $table->string('category_name')->nullable();
            $table->string('location')->nullable();
            $table->decimal('price_min', 15, 2)->nullable();
            $table->decimal('price_max', 15, 2)->nullable();
            $table->string('currency', 3)->nullable();
            $table->string('phone', 32);
            $table->string('locale', 5)->nullable();
            $table->string('status')->default('new'); // new | contacted | closed
            $table->timestamps();

            $table->index(['status', 'created_at']);
        });
    }

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