fix: match hotel codes assigned to users at beginning or end

This commit is contained in:
Björn Fromme
2025-01-06 12:22:39 +01:00
parent 5a07d95837
commit edaa294cc9
3 changed files with 14 additions and 24 deletions
+11 -13
View File
@@ -69,20 +69,18 @@ class DispositionVoter extends Voter
return false;
}
$hotels = $this
->hotelDataProvider
->findByCode($token->getUser()->getHotelCode())
;
$hotelBusProIds = array_map(function (Hotel $hotel) {
return $hotel->getBusProId();
}, $hotels);
$destination = $disposition
->getAssignment()
->getDestination()
;
$userHotelCode = $token->getUser()->getHotelCode();
return in_array($destination->getHotelBusProId(), $hotelBusProIds)
&& $destination->getDateTo() < new \DateTimeImmutable();
$destination = $disposition
->getAssignment()
->getDestination()
;
$isMatchingHotel = str_starts_with($destination->getHotelCode(), $userHotelCode)
|| str_ends_with($destination->getHotelCode(), $userHotelCode);
$isPast = $destination->getDateTo() < new \DateTimeImmutable();
return $isMatchingHotel && $isPast;
}
private function assertTeamerAccess(Disposition $disposition): bool