user(); if (! $user) { return to_route('login'); } $notification = $user->notifications()->findOrFail($id); $notification->markAsRead(); // Modular pattern: Match notification type to determine where to redirect $url = match ($notification->type) { TicketRaisedNotification::class, TicketAssignedNotification::class, TicketCommentedNotification::class, TicketStatusChangedNotification::class => route('tickets.index', [ 'ticket' => data_get($notification->data, 'ticket_id'), ]), // Future expansion: // \App\Notifications\AppExpiredNotification::class => route('apps.index', ['app' => data_get($notification->data, 'app_id')]), default => route('dashboard'), }; return redirect($url); } }