- Added migration for ticket assignment and comments (`assigned_user_id` and `ticket_replies` table). - Implemented `TicketAssignedNotification` and `TicketCommentedNotification`. - Created `ReplyData`, `TicketListData`, and `PostReplyRequest` data classes. - Introduced `ResolveNotificationRouteController` for modular notification redirection. - Updated UI to support assigning users and posting comments on tickets. - User is navigated to comments page when clicked on the ticket, upon navigation ticket details modal is opened. - Extended tests to cover assignments, comments, status transitions, and notifications.
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Notifications\{TicketAssignedNotification, TicketCommentedNotification, TicketRaisedNotification};
|
|
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 => 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);
|
|
}
|
|
}
|