diff --git a/app/Http/Controllers/Sales/DeliveryNoteController.php b/app/Http/Controllers/Sales/DeliveryNoteController.php index d5a42e1..f45ca52 100644 --- a/app/Http/Controllers/Sales/DeliveryNoteController.php +++ b/app/Http/Controllers/Sales/DeliveryNoteController.php @@ -11,6 +11,7 @@ use App\Models\SalesOrderItem; use App\Models\StockLevel; use App\Models\StockMovement; use App\Models\Warehouse; +use App\Notifications\Sales\DeliveryDispatchedNotification; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -145,6 +146,10 @@ class DeliveryNoteController extends Controller } }); + if ($deliveryNote->customer && $deliveryNote->customer->whatsapp_number) { + $deliveryNote->customer->notify(new DeliveryDispatchedNotification($deliveryNote)); + } + return redirect()->back()->with('success', 'Delivery note dispatched and stock decremented.'); } } diff --git a/app/Notifications/Sales/DeliveryDispatchedNotification.php b/app/Notifications/Sales/DeliveryDispatchedNotification.php new file mode 100644 index 0000000..b38d77e --- /dev/null +++ b/app/Notifications/Sales/DeliveryDispatchedNotification.php @@ -0,0 +1,29 @@ +name},\n\nYour delivery *#{$this->delivery->delivery_number}* has been dispatched and is on its way.\n\nOrder Reference: {$this->delivery->salesOrder->order_number}\nDispatch Date: {$this->delivery->delivery_date}\n\nThank you for your business." + ); + } +}