From 639282f707e66de8419ff1bc82d12c30b0d77f7c Mon Sep 17 00:00:00 2001 From: Ghassan Yusuf Date: Tue, 19 May 2026 13:19:27 +0300 Subject: [PATCH] feat: send WhatsApp notification on GRN confirmed --- .../Purchase/GoodsReceiptNoteController.php | 4 +++ .../GoodsReceiptConfirmedNotification.php | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php diff --git a/app/Http/Controllers/Purchase/GoodsReceiptNoteController.php b/app/Http/Controllers/Purchase/GoodsReceiptNoteController.php index f3584b6..6a6e981 100644 --- a/app/Http/Controllers/Purchase/GoodsReceiptNoteController.php +++ b/app/Http/Controllers/Purchase/GoodsReceiptNoteController.php @@ -9,6 +9,7 @@ use App\Models\PurchaseOrder; use App\Models\StockLevel; use App\Models\StockMovement; use App\Models\Warehouse; +use App\Notifications\Purchase\GoodsReceiptConfirmedNotification; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -145,6 +146,9 @@ class GoodsReceiptNoteController extends Controller } }); + $storeManagers = \App\Models\User::role('Store Manager')->whereNotNull('whatsapp_number')->get(); + \Illuminate\Support\Facades\Notification::send($storeManagers, new GoodsReceiptConfirmedNotification($grn)); + return redirect()->back()->with('success', 'GRN confirmed and stock updated.'); } } diff --git a/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php b/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php new file mode 100644 index 0000000..9bfd060 --- /dev/null +++ b/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php @@ -0,0 +1,29 @@ +grn->grn_number}* has been confirmed and goods received.\n\nPO Reference: {$this->grn->purchaseOrder->po_number}\nDate: {$this->grn->received_date}" + ); + } +}