<?php

declare(strict_types=1);

use App\Enums\PropertyProposalStatus;
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('property_proposals', function (Blueprint $table) {
            $table->id();
            $table->foreignId('request_id')->constrained('property_requests')->cascadeOnDelete();
            $table->foreignId('proposed_by_user_id')->constrained('users')->cascadeOnDelete();
            $table->string('title');
            $table->string('property_type');
            $table->foreignId('city_id')->nullable()->constrained()->nullOnDelete();
            $table->foreignId('zone_id')->nullable()->constrained()->nullOnDelete();
            $table->decimal('price', 15, 2)->nullable();
            $table->unsignedSmallInteger('surface')->nullable();
            $table->unsignedTinyInteger('rooms')->nullable();
            $table->unsignedTinyInteger('bedrooms')->nullable();
            $table->text('description')->nullable();
            $table->string('commission_requested')->nullable();
            $table->string('status', 32)->default(PropertyProposalStatus::Pending->value);
            $table->timestamps();
        });
    }

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