<?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('lead_form_submissions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('chat_session_id')->constrained()->cascadeOnDelete();
            $table->string('name', 120)->nullable();
            $table->string('phone', 30)->nullable()->index();
            $table->string('email', 150)->nullable();
            $table->string('business_name', 150)->nullable();
            $table->string('business_type', 150)->nullable();
            $table->string('website')->nullable();
            $table->string('facebook_page')->nullable();
            $table->string('monthly_budget', 100)->nullable();
            $table->text('pain_point')->nullable();
            $table->json('extra_data')->nullable();
            $table->string('source', 60)->default('chatbot-form');
            $table->text('ip_address')->nullable();
            $table->text('user_agent')->nullable();
            $table->timestamps();
        });
    }

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