<?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('reports', function (Blueprint $table) {
            $table->id();
            $table->foreignId('reporter_id')->constrained('users')->onDelete('cascade');
            $table->tinyInteger('reported_item_type')->comment('1=property, 2=user, 3=service');
            $table->unsignedBigInteger('reported_item_id');
            $table->string('reason');
            $table->text('description')->nullable();
            $table->tinyInteger('status')->default(1)->comment('1=pending, 2=investigating, 3=resolved, 4=dismissed');
            $table->timestamps();
            
            // Indexes for better performance
            $table->index(['reporter_id', 'created_at']);
            $table->index(['reported_item_type', 'reported_item_id']);
            $table->index('status');
        });
    }

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