<?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::table('bookings', function (Blueprint $table) {
            $table->integer('number_of_customers')->default(1)->after('room_id');
            $table->decimal('price_per_night', 10, 2)->nullable()->after('number_of_customers');
            $table->integer('number_of_nights')->default(1)->after('price_per_night');
            $table->decimal('advance_payment', 10, 2)->default(0)->after('total_price');
            $table->decimal('due_amount', 10, 2)->default(0)->after('advance_payment');
            $table->text('observations')->nullable()->after('due_amount');
            $table->enum('booking_status', ['Confirmed', 'Checked In', 'Checked Out', 'Cancelled'])->default('Confirmed')->after('observations');
            $table->timestamp('checked_in_at')->nullable()->after('booking_status');
            $table->timestamp('checked_out_at')->nullable()->after('checked_in_at');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('bookings', function (Blueprint $table) {
            $table->dropColumn([
                'number_of_customers',
                'price_per_night',
                'number_of_nights',
                'advance_payment',
                'due_amount',
                'observations',
                'booking_status',
                'checked_in_at',
                'checked_out_at',
                'created_at',
                'updated_at'
            ]);
        });
    }
};
