<?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('day_tour_transfer_points', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('day_tour_id');

            // Transfer Point Information
            $table->string('location_name');
            $table->time('pickup_time');
            $table->text('notes')->nullable();
            $table->integer('sort_order')->default(0);

            // Location Details
            $table->text('address')->nullable();
            $table->decimal('latitude', 10, 8)->nullable();
            $table->decimal('longitude', 11, 8)->nullable();

            // Status
            $table->boolean('is_active')->default(true);

            $table->timestamps();
            $table->softDeletes();

            // Foreign Keys
            $table->foreign('day_tour_id')->references('id')->on('day_tours')->onDelete('cascade');

            // Indexes
            $table->index(['day_tour_id', 'sort_order']);
            $table->index(['day_tour_id', 'is_active']);
        });
    }

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