LjupkaBelmezova Posted October 19, 2021 Report Share Posted October 19, 2021 I am building blog commenting system, using laravel 5.8 and vue.js. I want to add paginate function to comments as per instructions https://adevait.com/laravel/laravel-overwriting-default-pagination-system. Now I can display five comments, and after I click load more, I want to show next five comments. I have no idea how to accomplish. I am glad if someone helps me out. comments.vue user Cancel Comment {{ comment.user.name }} {{ comment.body }} commentsController.php public function index(Post $post) { return $post->comments()->with(‘user’)->paginate(5); } ResultsController.php public function show(Post $post) { $recommended_posts = Post::latest() ->whereDate(‘date’,’>’,date(‘Y-m-d’)) ->where(‘category_id’,’=’,$post->category_id) ->where(‘id’,’!=’,$post->id) ->limit(7) ->get(); // load the post comments here $post->load('comments'); $posts['particular_post'] = $post; $posts['recommended_posts'] = $recommended_posts; return view('posts.show',compact('posts')); } show.blade.php Route::get(‘results/{post}’, ‘ResultsController@show’)->name(‘posts.show’); Route::get(‘results/{post}/comments’, ‘CommentsController@index’); Quote Link to comment Share on other sites More sharing options...
administrator Posted October 19, 2021 Report Share Posted October 19, 2021 There must be a method in the paging class. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.