<?php

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

class AddReviewFieldsToLeadsTable extends Migration
{
    public function up()
    {
        Schema::table('leads', function (Blueprint $table) {
            $table->string('type')->default('offer')->after('company');
            $table->string('status')->default('approved')->after('type');
            $table->text('admin_note')->nullable()->after('trx');
            $table->timestamp('reviewed_at')->nullable()->after('admin_note');
            $table->foreignId('reviewed_by')->nullable()->after('reviewed_at')->constrained('users')->nullOnDelete();
            $table->timestamp('points_reversed_at')->nullable()->after('reviewed_by');
        });
    }

    public function down()
    {
        Schema::table('leads', function (Blueprint $table) {
            $table->dropConstrainedForeignId('reviewed_by');
            $table->dropColumn(['type', 'status', 'admin_note', 'reviewed_at', 'points_reversed_at']);
        });
    }
}
