user(); $commentId = $request->route('commentId'); $comment = Comment::find($commentId); if (!$comment) { return ResponseJson::pageNotFoundResponse('Comment not found', []); } if ($comment->user_id !== $user->id && $user->role !== 'admin') { return ResponseJson::forbidenResponse('Unauthorized to edit or delete this comment.', []); } return $next($request); } }