<?php

namespace Database\Factories;

use App\Enums\AppointmentStatus;
use App\Models\Appointment;
use App\Models\Business;
use App\Models\Customer;
use App\Models\Service;
use App\Models\StaffProfile;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class AppointmentFactory extends Factory
{
    protected $model = Appointment::class;

    public function definition(): array
    {
        $business = Business::factory();
        $startsAt = now()->addDays(fake()->numberBetween(1, 10))->setTime(fake()->numberBetween(9, 16), 0);

        return [
            'business_id' => $business,
            'customer_id' => Customer::factory(),
            'service_id' => Service::factory(),
            'staff_profile_id' => StaffProfile::factory(),
            'booking_number' => 'BK-'.fake()->unique()->numberBetween(10000, 99999),
            'status' => AppointmentStatus::Confirmed->value,
            'starts_at' => $startsAt,
            'ends_at' => $startsAt->copy()->addHour(),
            'duration_minutes' => 60,
            'price' => fake()->numberBetween(25, 250),
            'payment_status' => 'unpaid',
            'cancel_token' => Str::uuid()->toString(),
            'reschedule_token' => Str::uuid()->toString(),
        ];
    }
}
