@jlrdw the pagination its show correctly but not the link function
Then you are not properly appending the links.
{{ $users->appends(['color' => 'blue'])->links() }}
Contained in https://laravel.com/docs/5.5/pagination#displaying-pagination-results
@jirdw but the url he showed contains both the slug he's using to get the post and the page route parameter. What else would he need to append?
@ftrillo OP needs to write a view to display his data for testing. If the paginator won't work there it will never work.
@jlrdw please read the whole thread not just jump in at the end with obs that take us back 2 days
@Snapey I did, he said same info was showing on page 2. The parameter (slug) isn't being included, he is just paginating page 1 over and over.
Probably needs a length aware paginator for pretty url.
sorry to bother you guys, I'm working on this website alone because my friends just don't want to help me, while I have to go to college till night. this makes my brain performance decrease and can not make logic
@jlrdw if the slug was not included then the post would not be loaded. It is. The op is trying to pagination through related comments not the subject of the slug
@shawnmilke1 that's fine. I'm not a good person, just bored.
At this point I probably want to see what's wrong as much as you do.
Let's check some stuff and see If the problem becomes clear.
Please, check the ammount of comments the post in question has.
dd(Comment::where('post_id', $post->id)->count());
Then let's see what queries Laravel is running to paginate stuff: Put the code bellow in your controller show function, then navigate from page 1 to page 2. And show us what queries were saved to the laravel log.
public function show ($slug)
{
\DB::enableQueryLog(); // this enables query logging
$post = Post::where('slug',$slug)->firstOrFail();
$commentPaginator = Comment::where('post_id',$post->id)->paginate(10);
\Log::info(\DB::getQueryLog()); // this writes the queries in your log
return view('post.show')
->with(['post'=>$post,'commentPaginator'=>$commentPaginator]);
}
Please or to participate in this conversation.