feat: prevent booking flow without available rooms
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user