diff --git a/app/Livewire/OrderDelivery.php b/app/Livewire/OrderDelivery.php index e733549..acc2449 100644 --- a/app/Livewire/OrderDelivery.php +++ b/app/Livewire/OrderDelivery.php @@ -5,6 +5,7 @@ use App\Models\Order; use App\Models\Delivery; use App\Models\DeliveryAttachment; +use App\Notifications\OrderDelivered; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\Redirect; use Illuminate\View\View; @@ -52,6 +53,9 @@ public function saveDelivery(): RedirectResponse | Redirect | Redirector ]); } + // Notify the user that their order has been delivered + $this->order->user->notify(new OrderDelivered($this->order)); + session()->flash('success', 'Delivery created successfully.'); return redirect()->route('orders.show', $this->order); diff --git a/app/Notifications/OrderDelivered.php b/app/Notifications/OrderDelivered.php new file mode 100644 index 0000000..9d231ff --- /dev/null +++ b/app/Notifications/OrderDelivered.php @@ -0,0 +1,54 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage) + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +}