<?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('authorization_requests', function (Blueprint $table) {
            $table->id();
            $table->foreignId('account_id')->constrained('accounts')->onDelete('cascade');
            $table->foreignId('access_log_id')->constrained('access_logs')->onDelete('cascade');
            $table->string('requested_to_name'); // Nombre de la persona a la que se le solicita autorizar (ej: Propietario Casa 12B)
            $table->string('status')->default('pending'); // pending, approved, rejected
            $table->timestamp('responded_at')->nullable();
            $table->timestamps();
        });
    }

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