<?php

namespace Database\Factories;

use App\Enums\BookingStatus;
use App\Models\Booking;
use App\Models\Customer;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<Booking>
 */
class BookingFactory extends Factory
{
    protected $model = Booking::class;

    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $eventStart = Carbon::parse(fake()->dateTimeBetween('+1 week', '+2 months'));
        $eventEnd = $eventStart->copy()->addHours(fake()->numberBetween(2, 8));

        return [
            'booking_number' => 'BKG-'.now()->year.'-'.fake()->unique()->numerify('######'),
            'customer_id' => Customer::factory(),
            'contact_name' => fake()->name(),
            'contact_phone' => fake()->phoneNumber(),
            'contact_email' => fake()->safeEmail(),
            'event_name' => fake()->sentence(3),
            'event_type_id' => null,
            'description' => fake()->optional()->paragraph(),
            'event_start' => $eventStart,
            'event_end' => $eventEnd,
            'guest_count' => fake()->numberBetween(20, 200),
            'billable_days' => 1,
            'billable_hours' => 4,
            'seating_arrangement' => fake()->optional()->randomElement(['Theatre', 'Classroom', 'Banquet']),
            'coordinator_id' => null,
            'status' => BookingStatus::Enquiry,
            'subtotal' => 0,
            'discount_amount' => 0,
            'service_charge_amount' => 0,
            'tax_amount' => 0,
            'grand_total' => 0,
            'amount_paid' => 0,
            'outstanding_balance' => 0,
        ];
    }
}
