Skip to content

Commit 6189501

Browse files
authored
Merge pull request #18131 from Godmartinz/fix-inventory-alert-notification-misfire
Adds a null check for items and threshold in inventory alert notification
2 parents dfc6cdc + 32d4303 commit 6189501

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/Notifications/InventoryAlert.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace App\Notifications;
44

5+
use AllowDynamicProperties;
56
use Illuminate\Bus\Queueable;
67
use Illuminate\Notifications\Messages\MailMessage;
78
use Illuminate\Notifications\Notification;
89

10+
#[AllowDynamicProperties]
911
class InventoryAlert extends Notification
1012
{
1113
use Queueable;
@@ -32,9 +34,8 @@ public function __construct($params, $threshold)
3234
*/
3335
public function via()
3436
{
35-
$notifyBy = ['mail'];
37+
return (!empty($this->items) && $this->threshold !== null) ? ['mail'] : [];
3638

37-
return $notifyBy;
3839
}
3940

4041
/**

0 commit comments

Comments
 (0)