fix: consider participant's age at travel date
This commit is contained in:
@@ -343,12 +343,12 @@ class BookingService
|
|||||||
|
|
||||||
// Get age-appropriate mandatory services for this participant
|
// Get age-appropriate mandatory services for this participant
|
||||||
$ageAppropriateServices = array_filter($mandatoryServices, function ($service) use ($bookingDto, $participant) {
|
$ageAppropriateServices = array_filter($mandatoryServices, function ($service) use ($bookingDto, $participant) {
|
||||||
// Use the age evaluator service to check if service is appropriate for participant age
|
|
||||||
if (null === $service->ageFrom && null === $service->ageTo) {
|
if (null === $service->ageFrom && null === $service->ageTo) {
|
||||||
return true; // No age restrictions
|
return true; // No age restrictions
|
||||||
}
|
}
|
||||||
|
|
||||||
$age = $participant->dateOfBirth->diff($bookingDto->travel->dateFrom)->y;
|
// participant's age at travel date is relevant
|
||||||
|
$age = $participant->getAge($bookingDto->travel->dateFrom);
|
||||||
|
|
||||||
if (null !== $service->ageFrom && $age < $service->ageFrom) {
|
if (null !== $service->ageFrom && $age < $service->ageFrom) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user