From d30c3e0ccd4ffc02adf9f9aac9195cdb91f78641 Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Mon, 8 Jun 2020 16:17:13 +0200 Subject: [PATCH] push to save progress --- ...rices_to_booking_product_event_tickets.php | 36 +++++++++++++ .../src/Models/BookingProductEventTicket.php | 5 +- .../BookingProductEventTicketRepository.php | 25 +++++++++ .../src/Resources/lang/en/app.php | 3 ++ .../accordians/booking/event.blade.php | 54 ++++++++++++++----- 5 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 packages/Webkul/BookingProduct/src/Database/Migrations/2020_06_08_161708_add_sale_prices_to_booking_product_event_tickets.php diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2020_06_08_161708_add_sale_prices_to_booking_product_event_tickets.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2020_06_08_161708_add_sale_prices_to_booking_product_event_tickets.php new file mode 100644 index 000000000..3632937cd --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2020_06_08_161708_add_sale_prices_to_booking_product_event_tickets.php @@ -0,0 +1,36 @@ +decimal('special_price', 12,4)->after('qty')->nullable(); + $table->dateTime('special_price_from')->after('special_price')->nullable(); + $table->dateTime('special_price_to')->after('special_price_from')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('booking_product_event_tickets', function (Blueprint $table) { + $table->dropColumn('special_price'); + $table->dropColumn('special_price_from'); + $table->dropColumn('special_price_to'); + }); + } +} diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductEventTicket.php b/packages/Webkul/BookingProduct/src/Models/BookingProductEventTicket.php index 45be2194b..ec35a5788 100644 --- a/packages/Webkul/BookingProduct/src/Models/BookingProductEventTicket.php +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductEventTicket.php @@ -10,10 +10,13 @@ class BookingProductEventTicket extends TranslatableModel implements BookingProd public $timestamps = false; public $translatedAttributes = ['name', 'description']; - + protected $fillable = [ 'price', 'qty', + 'special_price', + 'special_price_from', + 'special_price_to', 'booking_product_id', ]; } \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php b/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php index cbb19109c..ce0a1a7f2 100644 --- a/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php +++ b/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php @@ -28,6 +28,31 @@ class BookingProductEventTicketRepository extends Repository if (isset($data['tickets'])) { foreach ($data['tickets'] as $ticketId => $ticketInputs) { + + if ( + ! array_key_exists('special_price', $ticketInputs) + || empty($ticketInputs['special_price']) + || $ticketInputs['special_price'] === '0.0000' + ) { + $ticketInputs['special_price'] = null; + } + + if ( + ! array_key_exists('special_price_from', $ticketInputs) + || empty($ticketInputs['special_price_from']) + || $ticketInputs['special_price_from'] === '0000-00-00 00:00:00' + ) { + $ticketInputs['special_price_from'] = null; + } + + if ( + ! array_key_exists('special_price_to', $ticketInputs) + || empty($ticketInputs['special_price_to']) + || $ticketInputs['special_price_to'] === '0000-00-00 00:00:00' + ) { + $ticketInputs['special_price_to'] = null; + } + if (Str::contains($ticketId, 'ticket_')) { $this->create(array_merge([ 'booking_product_id' => $bookingProduct->id, diff --git a/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php b/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php index 34d2f8641..034010f55 100644 --- a/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php +++ b/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php @@ -48,6 +48,9 @@ return [ 'price' => 'Price', 'quantity' => 'Quantity', 'description' => 'Description', + 'special-price' => 'Special Price', + 'special-price-from' => 'Valid From', + 'special-price-to' => 'Valid Until', 'charged-per' => 'Charged Per', 'guest' => 'Guest', 'table' => 'Table', diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php index d56467c58..6e55e635d 100644 --- a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php @@ -17,7 +17,7 @@
- +
@@ -26,16 +26,6 @@ -@endpush \ No newline at end of file + +@endpush