From 371b75193ae164cdac63db3d699cf26f3dff3534 Mon Sep 17 00:00:00 2001 From: Daan Meijer Date: Mon, 6 Jul 2026 11:50:24 +0200 Subject: [PATCH] notificaties bij activiteit --- app/Http/Controllers/MutationController.php | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/Http/Controllers/MutationController.php b/app/Http/Controllers/MutationController.php index afce75e..9b1a8bc 100644 --- a/app/Http/Controllers/MutationController.php +++ b/app/Http/Controllers/MutationController.php @@ -9,9 +9,11 @@ use App\Http\Requests\StoreMutationRequest; use App\Models\Dynamic; use App\Models\Ledger; use App\Models\Mutation; +use App\Notifications\NewActivityNotification; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Notification; class MutationController extends Controller { @@ -76,6 +78,17 @@ class MutationController extends Controller return $mutation; }); + // Notify all other participants + $recipients = $dynamic->participants()->where('users.id', '!=', $request->user()->id)->get(); + $message = $status === 'approved' + ? "{$request->user()->name} added a new entry: \"{$mutation->description}\"." + : "{$request->user()->name} suggested a new entry: \"{$mutation->description}\"."; + + Notification::send($recipients, new NewActivityNotification([ + 'content' => $message, + 'url' => route('dynamics.ledgers.show', [$dynamic, $ledger]), + ])); + return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]); } @@ -151,6 +164,13 @@ class MutationController extends Controller } broadcast(new MessageSent($dynamicMsg)); + // Notify all other participants + $recipients = $dynamic->participants()->where('users.id', '!=', $request->user()->id)->get(); + Notification::send($recipients, new NewActivityNotification([ + 'content' => "{$user->name} {$statusText} the suggestion: \"{$mutation->description}\".", + 'url' => route('dynamics.ledgers.show', [$dynamic, $ledger]), + ])); + return redirect()->back(); } @@ -160,6 +180,13 @@ class MutationController extends Controller $mutation->update(['status' => 'voided']); + // Notify all other participants + $recipients = $dynamic->participants()->where('users.id', '!=', $request->user()->id)->get(); + Notification::send($recipients, new NewActivityNotification([ + 'content' => "{$request->user()->name} voided an entry: \"{$mutation->description}\".", + 'url' => route('dynamics.ledgers.show', [$dynamic, $ledger]), + ])); + return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]); }