From dc5404c33d67d4977418d0170bb8b56c50c7a999 Mon Sep 17 00:00:00 2001 From: jitendra Date: Tue, 9 Aug 2022 18:07:35 +0530 Subject: [PATCH] Booking package refactored --- .../Webkul/BookingProduct/src/Helpers/Booking.php | 11 ++++++++++- .../BookingProduct/src/Helpers/DefaultSlot.php | 6 +++--- .../BookingProduct/src/Helpers/EventTicket.php | 12 ++++++++++-- .../Controllers/Shop/BookingProductController.php | 10 +++++----- .../BookingProductEventTicketRepository.php | 5 ++--- .../Webkul/BookingProduct/src/Type/Booking.php | 14 +++++++------- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/packages/Webkul/BookingProduct/src/Helpers/Booking.php b/packages/Webkul/BookingProduct/src/Helpers/Booking.php index 72f3eccc4..7baca2de7 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/Booking.php +++ b/packages/Webkul/BookingProduct/src/Helpers/Booking.php @@ -37,7 +37,15 @@ class Booking /** * @return array */ - protected $daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + protected $daysOfWeek = [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + ]; /** * Create a new helper instance. @@ -222,6 +230,7 @@ class Booking foreach ($slots as $index => $slot) { $slots[$index]['from'] = Carbon::createFromTimeString($slot['from'])->format("h:i a"); + $slots[$index]['to'] = Carbon::createFromTimeString($slot['to'])->format("h:i a"); } diff --git a/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php b/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php index efaab52d3..b6ec3bc63 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php +++ b/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php @@ -12,7 +12,7 @@ class DefaultSlot extends Booking protected $daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; /** - * Returns slots for a perticular day + * Returns slots for a particular day * * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct * @param string $date @@ -52,7 +52,7 @@ class DefaultSlot extends Booking return $bookingProductSlot->booking_type == 'one' ? $this->getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate) - : $this->getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate); + : $this->getManyBookingsForOneDaySlots($bookingProductSlot, $requestedDate); } /** @@ -98,7 +98,7 @@ class DefaultSlot extends Booking * @param string $requestedDate * @return array */ - public function getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate) + public function getManyBookingsForOneDaySlots($bookingProductSlot, $requestedDate) { $bookingProduct = $bookingProductSlot->booking_product; diff --git a/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php b/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php index 6d5798979..3f45f030b 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php +++ b/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php @@ -187,7 +187,15 @@ class EventTicket extends Booking { return $ticket->special_price !== null && $ticket->special_price > 0.0 - && ($ticket->special_price_from === null || $ticket->special_price_from === '0000-00-00 00:00:00' || $ticket->special_price_from <= Carbon::now()) - && ($ticket->special_price_to === null || $ticket->special_price_to === '0000-00-00 00:00:00' || $ticket->special_price_to > Carbon::now()); + && ( + $ticket->special_price_from === null + || $ticket->special_price_from === '0000-00-00 00:00:00' + || $ticket->special_price_from <= Carbon::now() + ) + && ( + $ticket->special_price_to === null + || $ticket->special_price_to === '0000-00-00 00:00:00' + || $ticket->special_price_to > Carbon::now() + ); } } \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php b/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php index f15e512b0..e4e5ee72e 100644 --- a/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php +++ b/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php @@ -21,11 +21,11 @@ class BookingProductController extends Controller * Create a new controller instance. * * @param \Webkul\BookingProduct\Repositories\BookingProductRepository $bookingProductRepository - * @param \Webkul\BookingProduct\Helpers\DefaultSlot $defaultSlotHelper - * @param \Webkul\BookingProduct\Helpers\AppointmentSlot $appointmentSlotHelper - * @param \Webkul\BookingProduct\Helpers\RentalSlot $rentalSlotHelper - * @param \Webkul\BookingProduct\Helpers\EventTicket $EventTicketHelper - * @param \Webkul\BookingProduct\Helpers\TableSlot $tableSlotHelper + * @param \Webkul\BookingProduct\Helpers\DefaultSlot $defaultSlotHelper + * @param \Webkul\BookingProduct\Helpers\AppointmentSlot $appointmentSlotHelper + * @param \Webkul\BookingProduct\Helpers\RentalSlot $rentalSlotHelper + * @param \Webkul\BookingProduct\Helpers\EventTicket $EventTicketHelper + * @param \Webkul\BookingProduct\Helpers\TableSlot $tableSlotHelper * @return void */ public function __construct( diff --git a/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php b/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php index 57e0e3a3c..d481f00c3 100644 --- a/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php +++ b/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php @@ -19,9 +19,8 @@ class BookingProductEventTicketRepository extends Repository } /** - * @param array $data - * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct - * + * @param array $data + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct * @return void * @throws \Prettus\Validator\Exceptions\ValidatorException */ diff --git a/packages/Webkul/BookingProduct/src/Type/Booking.php b/packages/Webkul/BookingProduct/src/Type/Booking.php index 38e67f8a0..d06f2bf67 100644 --- a/packages/Webkul/BookingProduct/src/Type/Booking.php +++ b/packages/Webkul/BookingProduct/src/Type/Booking.php @@ -40,14 +40,14 @@ class Booking extends Virtual /** * Create a new product type instance. * - * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository - * @param \Webkul\Product\Repositories\ProductRepository $productRepository - * @param \Webkul\Product\Repositories\ProductAttributeValueRepository $attributeValueRepository - * @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository - * @param \Webkul\Product\Repositories\ProductImageRepository $productImageRepository + * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository + * @param \Webkul\Product\Repositories\ProductRepository $productRepository + * @param \Webkul\Product\Repositories\ProductAttributeValueRepository $attributeValueRepository + * @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository + * @param \Webkul\Product\Repositories\ProductImageRepository $productImageRepository * @param \Webkul\BookingProduct\Repositories\BookingProductRepository $bookingProductRepository - * @param \Webkul\BookingProduct\Helpers\BookingHelper $bookingHelper - * @param \Webkul\Product\Repositories\ProductVideoRepository $productVideoRepository + * @param \Webkul\BookingProduct\Helpers\BookingHelper $bookingHelper + * @param \Webkul\Product\Repositories\ProductVideoRepository $productVideoRepository * @return void */ public function __construct(