From 584c0ab1f2765336207d3ba2b0286c270f813985 Mon Sep 17 00:00:00 2001 From: xGrz <33755434+xGrz@users.noreply.github.com> Date: Sat, 15 Jun 2024 11:32:46 +0200 Subject: [PATCH] Added message when courier booking has date from future. Added flash message confirmation for booking. --- .../livewire/create-single-shipment-booking.blade.php | 8 +++++++- src/Livewire/CreateSingleShipmentBooking.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/views/shipments/livewire/create-single-shipment-booking.blade.php b/resources/views/shipments/livewire/create-single-shipment-booking.blade.php index 3a54805..bd722d5 100644 --- a/resources/views/shipments/livewire/create-single-shipment-booking.blade.php +++ b/resources/views/shipments/livewire/create-single-shipment-booking.blade.php @@ -1,10 +1,16 @@ +@php use Illuminate\Support\Carbon; @endphp
@foreach($dateOptions as $pickupDateOption) - + @endforeach + @if (!Carbon::parse($pickupDate)->isToday()) +
You book a courier with a future date
+ @endif
diff --git a/src/Livewire/CreateSingleShipmentBooking.php b/src/Livewire/CreateSingleShipmentBooking.php index b57a172..0493004 100644 --- a/src/Livewire/CreateSingleShipmentBooking.php +++ b/src/Livewire/CreateSingleShipmentBooking.php @@ -42,6 +42,7 @@ public function book() $to = Carbon::parse($this->pickupDate . ' ' . $this->pickupTo); try { DHL24::booking()->book($from, $to, $this->shipment, $this->comment); + session()->flash('success', 'Courier successfully booked for ' . $from->format('d-m-Y') . ' between ' . $from->format('H:i') . '-' . $to->format('H:i')); $this->redirectRoute('dhl24.shipments.index'); } catch (DHL24Exception $e) { $this->dispatch('openModal', component: 'shipment-create-error', arguments: ['title' => 'Courier booking failed', 'message' => $e->getMessage()]);