<?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('properties', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->string('slug')->unique();
            $table->text('description');
            $table->decimal('price', 15, 2);
            $table->string('property_type'); // House, Villa, Land, Apartment, Commercial
            $table->string('status'); // Buy, Rent, Sold
            $table->boolean('featured')->default(false);
            $table->integer('bedrooms')->default(0);
            $table->integer('bathrooms')->default(0);
            $table->integer('sqft')->default(0);
            $table->string('address');
            $table->string('city');
            $table->string('state')->default('Lagos');
            $table->string('country')->default('Nigeria');
            $table->string('title_document')->nullable(); // C of O, Governor's Consent, Gazette, Deed of Assignment
            $table->json('features')->nullable(); // Security, Swimming Pool, Gated Estate, etc.
            $table->json('images'); // array of image paths
            $table->foreignId('agent_id')->nullable()->constrained('agents')->onDelete('set null');
            $table->timestamps();
        });
    }

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