From eb4e015af509daec5c281a4f5c4b61b5e380d1d2 Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Sat, 13 Jul 2024 00:03:04 +0200 Subject: [PATCH] make new NotificationService (not tested) --- app/Services/NotificationService.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index b997f70..cf82a1b 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -9,8 +9,15 @@ class NotificationService{ public static function sendEntityNotification(Entity $entity,$notification){ $admins = User::activeAdmins()->select('id', 'email')->get(); + + $operators = $entity->operators->pluck('id')->toArray(); + + $filteredAdmins = $admins->filter(function ($admin) use ($operators) { + return !in_array($admin->id, $operators); + }); + Notification::sendNow($entity->operators, new $notification($entity)); - Notification::sendNow($admins, new $notification($entity)); + Notification::sendNow($filteredAdmins, new $notification($entity)); } }