From 12d802693384c8de674c23bcaf3c3e86314904da Mon Sep 17 00:00:00 2001 From: EwelinaSkrzypacz Date: Wed, 4 Dec 2024 12:48:56 +0100 Subject: [PATCH] - fix double notifications --- app/Actions/VacationRequest/ApproveAction.php | 5 ++++- app/Actions/VacationRequest/CancelAction.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Actions/VacationRequest/ApproveAction.php b/app/Actions/VacationRequest/ApproveAction.php index a3d2541a..98ed6bf7 100644 --- a/app/Actions/VacationRequest/ApproveAction.php +++ b/app/Actions/VacationRequest/ApproveAction.php @@ -35,7 +35,10 @@ public function execute(VacationRequest $vacationRequest, ?User $user = null): v protected function notify(VacationRequest $vacationRequest): void { - $users = Permission::findByName("receiveVacationRequestStatusChangedNotification")->users()->get(); + $users = Permission::findByName("receiveVacationRequestStatusChangedNotification") + ->users() + ->where("id", "!=", $vacationRequest->user->id) + ->get(); foreach ($users as $user) { $user->notify(new VacationRequestStatusChangedNotification($vacationRequest, $user)); diff --git a/app/Actions/VacationRequest/CancelAction.php b/app/Actions/VacationRequest/CancelAction.php index b0851ef2..a99783e6 100644 --- a/app/Actions/VacationRequest/CancelAction.php +++ b/app/Actions/VacationRequest/CancelAction.php @@ -35,7 +35,10 @@ public function execute(VacationRequest $vacationRequest, User $user): void protected function notify(VacationRequest $vacationRequest): void { - $users = Permission::findByName("receiveVacationRequestStatusChangedNotification")->users()->get(); + $users = Permission::findByName("receiveVacationRequestStatusChangedNotification") + ->users() + ->where("id", "!=", $vacationRequest->user->id) + ->get(); foreach ($users as $user) { $user->notify(new VacationRequestStatusChangedNotification($vacationRequest, $user));