Jump to content

LjupkaBelmezova

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by LjupkaBelmezova

  1. 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’);
×
×
  • Create New...