<?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('hostels', function (Blueprint $table) {
            $table->id();
            $table->foreignId('property_id')->constrained('properties')->onDelete('cascade');
            $table->string('university_nearby');
            $table->decimal('distance_to_university', 5, 2); // km
            $table->tinyInteger('room_sharing')->comment('1=single, 2=double, 3=triple');
            $table->tinyInteger('gender_restriction')->comment('1=male, 2=female, 3=mixed');
            $table->boolean('meal_plan_available')->default(false);
            $table->boolean('study_room_available')->default(false);
            $table->time('curfew_time')->nullable();
            $table->timestamps();
            
            // Indexes for better performance
            $table->index('property_id');
            $table->index(['university_nearby', 'gender_restriction']);
        });
    }

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