<?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('booking_price_adjustments', function (Blueprint $table) {
            $table->id();
            // 🧠 type of rule
            $table->string('type');
            // tax, discount, service_fee, coupon, guest_fee, seasonal

            $table->string('name');
            $table->text('description')->nullable();

            // 💰 rule value
            $table->decimal('value', 10, 2);
            $table->enum('value_type', ['fixed', 'percentage'])->default('fixed');

            // ➕ add or subtract
            $table->enum('direction', ['add', 'subtract']);

            // 🏨 CONDITIONS (simple, fixed fields)
            $table->integer('min_rooms')->nullable();
            $table->integer('max_rooms')->nullable();

            $table->integer('min_nights')->nullable();
            $table->integer('max_nights')->nullable();

            $table->decimal('min_total', 10, 2)->nullable();
            $table->decimal('max_total', 10, 2)->nullable();

            $table->date('start_date')->nullable();
            $table->date('end_date')->nullable();

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

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

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