From 32d43034bde7e4fe6825b76b12ce7756aadc5677 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 30 Oct 2025 10:47:17 -0700 Subject: [PATCH] add a null check for items and threshold in inventory alert notification --- app/Notifications/InventoryAlert.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Notifications/InventoryAlert.php b/app/Notifications/InventoryAlert.php index 6d59e3b42a..a4c27ab902 100644 --- a/app/Notifications/InventoryAlert.php +++ b/app/Notifications/InventoryAlert.php @@ -2,10 +2,12 @@ namespace App\Notifications; +use AllowDynamicProperties; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +#[AllowDynamicProperties] class InventoryAlert extends Notification { use Queueable; @@ -32,9 +34,8 @@ class InventoryAlert extends Notification */ public function via() { - $notifyBy = ['mail']; + return (!empty($this->items) && $this->threshold !== null) ? ['mail'] : []; - return $notifyBy; } /**