From 358907bbed9d951086d979c6328536a76e090cd8 Mon Sep 17 00:00:00 2001 From: Ghassan Yusuf Date: Tue, 19 May 2026 13:19:21 +0300 Subject: [PATCH] feat: send WhatsApp notification on PO confirmed --- .../Purchase/PurchaseOrderController.php | 5 ++++ .../PurchaseOrderConfirmedNotification.php | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php diff --git a/app/Http/Controllers/Purchase/PurchaseOrderController.php b/app/Http/Controllers/Purchase/PurchaseOrderController.php index 00caab0..aba95fd 100644 --- a/app/Http/Controllers/Purchase/PurchaseOrderController.php +++ b/app/Http/Controllers/Purchase/PurchaseOrderController.php @@ -8,6 +8,7 @@ use App\Models\PurchaseOrder; use App\Models\PurchaseOrderItem; use App\Models\PurchaseRequest; use App\Models\Supplier; +use App\Notifications\Purchase\PurchaseOrderConfirmedNotification; use Illuminate\Http\Request; class PurchaseOrderController extends Controller @@ -62,6 +63,10 @@ class PurchaseOrderController extends Controller ]); } + if ($order->supplier && $order->supplier->whatsapp_number) { + $order->supplier->notify(new PurchaseOrderConfirmedNotification($order)); + } + return redirect()->route('purchase.orders.show', $order)->with('success', 'Purchase order created successfully.'); } diff --git a/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php b/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php new file mode 100644 index 0000000..ca0db0d --- /dev/null +++ b/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php @@ -0,0 +1,29 @@ +name},\n\nPurchase Order *#{$this->order->po_number}* has been confirmed.\n\nTotal Amount: {$this->order->total_amount}\nExpected Delivery: {$this->order->expected_delivery_date}\n\nThank you." + ); + } +}