feat: prevent booking flow without available rooms

This commit is contained in:
Björn Fromme
2025-09-24 11:14:45 +02:00
parent 5642193610
commit eed7ba4d7b
5 changed files with 71 additions and 7 deletions
+6
View File
@@ -4,6 +4,7 @@ namespace App\Service;
use App\BusProNet\Model\Room;
use App\BusProNet\Model\Travel;
use App\Exception\NoRoomsAvailableException;
use App\Form\Model\BookingCreateDto;
use App\Form\Model\RoomSelectionDto;
use Symfony\Component\HttpFoundation\Request;
@@ -78,6 +79,11 @@ class BookingService
$roomsIdsAndQuantities = $this->processRoomQuantities($request);
$availableRooms = $travelData->getAvailableRooms();
// Prevent booking flow entry when no rooms are available
if (empty($availableRooms)) {
throw new NoRoomsAvailableException($dateId, $hotelId);
}
$roomSelections = array_map(
fn (Room $room) => $this->createRoomSelection($room, $roomsIdsAndQuantities),
$availableRooms