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

            // Cultural Tour relationship
            $table->unsignedBigInteger('cultural_tour_id');

            // Basic pricing info
            $table->string('pricing_name'); // Standard, Premium, etc.
            $table->text('description')->nullable();

            // Price fields - Only adult, child, infant
            $table->decimal('adult_price', 10, 2)->nullable();
            $table->decimal('child_price', 10, 2)->nullable();
            $table->decimal('infant_price', 10, 2)->nullable();

            // Age ranges
            $table->integer('child_min_age')->nullable();
            $table->integer('child_max_age')->nullable();
            $table->integer('infant_max_age')->nullable();

            // Currency and basic settings
            $table->string('currency', 3)->default('TRY');
            $table->integer('sort_order')->default(0);
            $table->boolean('is_active')->default(true);
            $table->boolean('is_default')->default(false);

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

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

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

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