From a1f6e765e1eb13df437e9869d9bc38e803e247d4 Mon Sep 17 00:00:00 2001 From: Ghassan Yusuf Date: Tue, 19 May 2026 13:19:49 +0300 Subject: [PATCH] feat: send WhatsApp notification on production order completed --- .../Production/ProductionOrderController.php | 7 +++++ .../ProductionOrderCompletedNotification.php | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 app/Notifications/Production/ProductionOrderCompletedNotification.php diff --git a/app/Http/Controllers/Production/ProductionOrderController.php b/app/Http/Controllers/Production/ProductionOrderController.php index 643e545..f7a7da1 100644 --- a/app/Http/Controllers/Production/ProductionOrderController.php +++ b/app/Http/Controllers/Production/ProductionOrderController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Models\Item; use App\Models\ProductionCost; use App\Models\ProductionOrder; +use App\Notifications\Production\ProductionOrderCompletedNotification; use Illuminate\Http\Request; class ProductionOrderController extends Controller @@ -89,6 +90,12 @@ class ProductionOrderController extends Controller 'completion_date' => now(), ]); + $productionManagers = \App\Models\User::role('Production Manager')->whereNotNull('whatsapp_number')->get(); + \Illuminate\Support\Facades\Notification::send( + $productionManagers, + new ProductionOrderCompletedNotification($productionOrder) + ); + return redirect()->back()->with('success', 'Production order marked as completed.'); } } diff --git a/app/Notifications/Production/ProductionOrderCompletedNotification.php b/app/Notifications/Production/ProductionOrderCompletedNotification.php new file mode 100644 index 0000000..a32a112 --- /dev/null +++ b/app/Notifications/Production/ProductionOrderCompletedNotification.php @@ -0,0 +1,29 @@ +order->order_number}* has been completed.\n\nProduct: {$this->order->product->item_name}\nQuantity: {$this->order->quantity_to_produce}\nCompleted: " . now()->format('d M Y') + ); + } +}