with(['user', 'product']); if($authorId){ $comments = $comments->where('user_id', $authorId); } $comments = $comments->paginate(getPaginate()); return view('admin.comment.index', compact('pageTitle', 'comments')); } public function destroy($id) { $comment = Comment::findOrFail($id); $comment->delete(); $notify[] = ['success', 'Comment deleted']; return back()->withNotify($notify); } public function repliesList($commentId) { $pageTitle = 'Replies'; $comment = Comment::findOrFail($commentId); $replies = $comment->replies()->with(['user', 'product'])->paginate(getPaginate()); return view('admin.comment.reply.index', compact('pageTitle', 'replies')); } public function deleteReply($id) { $comment = Comment::findOrFail($id); $comment->delete(); $notify[] = ['success','Reply deleted']; return back()->withNotify($notify); } }