diff --git a/app/Notifications/InventoryAlert.php b/app/Notifications/InventoryAlert.php index 6d59e3b42a8f..a4c27ab90220 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 @@ public function __construct($params, $threshold) */ public function via() { - $notifyBy = ['mail']; + return (!empty($this->items) && $this->threshold !== null) ? ['mail'] : []; - return $notifyBy; } /**