singleloginsystem/app/Http/Controllers/ResolveNotificationRouteController.php
= 8a41ae6ac1 Feat: assigned user status change, search, pagination and notification
- Added activity logs for ticket status changes, comments, and ticket views.
- Implemented `TicketStatusChangedNotification` to notify users of status updates.
- Enhanced ticket list filtering with pagination, search, and status filters.
- Updated UI to better handle ticket assignments, status updates, and comment notifications.
- Extended tests for activity logs, unauthorized actions, status change notifications, and filtering functionalities.
2026-05-28 13:22:36 +00:00

40 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Notifications\{TicketAssignedNotification, TicketCommentedNotification, TicketRaisedNotification, TicketStatusChangedNotification};
use Illuminate\Http\Request;
class ResolveNotificationRouteController extends Controller
{
public function __invoke(Request $request, string $id)
{
$user = $request->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);
}
}