notificaties bij activiteit
Some checks failed
linter / quality (push) Failing after 1m5s
tests / ci (8.3) (push) Failing after 49s
tests / ci (8.4) (push) Failing after 1m5s
tests / ci (8.5) (push) Failing after 1m7s

This commit is contained in:
Daan Meijer 2026-07-06 11:50:24 +02:00
parent 57be9168e5
commit 371b75193a

View File

@ -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]);
}