fix: match hotel codes assigned to users at beginning or end
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user