diff --git a/app/Classes/Modules/Bookings/ControllersLogic/ListBookingsLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/ListBookingsLogic.php new file mode 100644 index 00000000..21ea2a37 --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/ListBookingsLogic.php @@ -0,0 +1,60 @@ + 'Retrieved Bookings', + 'message' => 'You have successfully retrieved a list of Bookings' + ]; + } + + /** @var CanListBookings */ + private $canListBookings; + + /** @var ListsBookings */ + private $listsBookings; + + /** + * ListBookingsLogic constructor. + * @param CanListBookings $canListBookings + * @param ListsBookings $listsBookings + */ + public function __construct(CanListBookings $canListBookings, ListsBookings $listsBookings) + { + $this->canListBookings = $canListBookings; + $this->listsBookings = $listsBookings; + } + + public function logic(Request $request) : JsonResponse + { + try { + $this->canListBookings->passes(); + + $query = $this->listsBookings->execute($this->listsBookings->deserializeFilters($request->input('filters'))); + + return $this->collectionResponse(BookingResource::collection($query)); + + } catch (\Exception $exception) { + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + + } + + + +} diff --git a/app/Classes/Modules/Bookings/Services/ListsBookings.php b/app/Classes/Modules/Bookings/Services/ListsBookings.php new file mode 100644 index 00000000..f2aa1f1c --- /dev/null +++ b/app/Classes/Modules/Bookings/Services/ListsBookings.php @@ -0,0 +1,31 @@ +repository = $repository; + } + + /** + * @return Booking + */ + public function getRepository(): Builder + { + return $this->repository; + } +} diff --git a/app/Classes/Modules/Bookings/Standards/Rules/CanListBookings.php b/app/Classes/Modules/Bookings/Standards/Rules/CanListBookings.php new file mode 100644 index 00000000..a66e9610 --- /dev/null +++ b/app/Classes/Modules/Bookings/Standards/Rules/CanListBookings.php @@ -0,0 +1,40 @@ +execute($request); + } +}