<?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('payment_proofs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('association_id')->constrained('associations')->cascadeOnDelete();
            $table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
            
            $table->string('bank_name');
            $table->string('account_name');
            $table->string('account_number');
            
            $table->decimal('amount', 12, 2);
            $table->date('transfer_date');
            
            $table->string('receipt_file_path');
            $table->enum('status', ['pending', 'verified', 'rejected'])->default('pending');
            
            $table->text('rejection_reason')->nullable();
            
            $table->foreignId('verified_by')->nullable()->constrained('users')->cascadeOnDelete();
            $table->timestamp('verified_at')->nullable();
            
            $table->timestamps();
            
            $table->index(['association_id', 'user_id', 'status']);
            $table->index(['status', 'verified_at']);
        });
    }

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