wip: booking process
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use Symfony\Component\Serializer\Attribute\Context;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
||||
@@ -101,7 +102,7 @@ class Travel
|
||||
$group = (array) $group;
|
||||
|
||||
$services = array_filter($this->additionalServices, function (Service $service) use ($group, $availableOnly) {
|
||||
return in_array($service->subType, $group) && (false === $availableOnly || $service->available > 0);
|
||||
return true === in_array($service->subType, $group) && (false === $availableOnly || 0 < $service->available);
|
||||
});
|
||||
|
||||
usort($services, function (Service $a, Service $b) {
|
||||
@@ -150,7 +151,7 @@ class Travel
|
||||
$services = [];
|
||||
|
||||
foreach (CrmSelectionGroup::$includedServicesMapping as $id => $label) {
|
||||
if (isset($this->selectionGroups[$id])) {
|
||||
if (true === isset($this->selectionGroups[$id])) {
|
||||
$services[] = $this->selectionGroups[$id];
|
||||
}
|
||||
}
|
||||
@@ -171,7 +172,7 @@ class Travel
|
||||
*/
|
||||
public function getRoomsByIds(array $ids): array
|
||||
{
|
||||
if (empty($ids)) {
|
||||
if (true === empty($ids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -180,4 +181,19 @@ class Travel
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all available rooms for booking.
|
||||
*
|
||||
* Filters the rooms collection to return only rooms that have availability
|
||||
* greater than zero and have an available status. This ensures only
|
||||
* bookable rooms are returned for selection.
|
||||
*
|
||||
* @return array<Room> The filtered array of available rooms
|
||||
*/
|
||||
public function getAvailableRooms(): array
|
||||
{
|
||||
return array_filter($this->rooms, function (Room $room) {
|
||||
return $room->available > 0 && $room->status === Constants::STATUS_AVAILABLE;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user