feat: mark unavailable services as read-only and add tooltip
This commit is contained in:
@@ -74,19 +74,34 @@ class ServiceAvailabilityCalculator
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specific service is available for the current participant.
|
||||
* Check if a specific service is unavailable (sold out) for the current participant.
|
||||
*
|
||||
* @param int $serviceId The ID of the service to check
|
||||
* @param BookingCreateDto $bookingDto The booking data with participant selections
|
||||
* @param int $participantIndex The index of the participant currently filling the form
|
||||
*
|
||||
* @return bool True if the service has remaining availability
|
||||
* @return bool True if the service is unavailable (has availability limit and remaining is 0)
|
||||
*/
|
||||
public function isServiceAvailable(int $serviceId, BookingCreateDto $bookingDto, int $participantIndex): bool
|
||||
public function isServiceUnavailable(int $serviceId, BookingCreateDto $bookingDto, int $participantIndex): bool
|
||||
{
|
||||
$allServices = $this->getAllServicesFromTravel($bookingDto);
|
||||
$service = null;
|
||||
|
||||
foreach ($allServices as $serviceObj) {
|
||||
if ($serviceObj->id === $serviceId) {
|
||||
$service = $serviceObj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If service not found or has no availability limit, it's not unavailable
|
||||
if (null === $service || null === $service->available || $service->available <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$remainingAvailability = $this->calculateRemainingAvailability($bookingDto, $participantIndex);
|
||||
|
||||
return ($remainingAvailability[$serviceId] ?? 0) > 0;
|
||||
return ($remainingAvailability[$serviceId] ?? $service->available) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user