Skip to content

A free open source IT asset/license management system

add a null check for items and threshold in inventory alert notification

Godfrey M32d43034bde7
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;
}
/**