mlazuardy

@jlrdw the pagination its show correctly but not the link function

jlrdw
jlrdw
1 week ago (195,930 XP)

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

ftrillo
ftrillo
1 week ago (12,140 XP)

@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?

jlrdw
jlrdw
1 week ago (195,930 XP)

@ftrillo OP needs to write a view to display his data for testing. If the paginator won't work there it will never work.

Snapey
Snapey
1 week ago (647,375 XP)

@jlrdw please read the whole thread not just jump in at the end with obs that take us back 2 days

jlrdw
jlrdw
1 week ago (195,930 XP)

@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.

mlazuardy

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

Snapey
Snapey
1 week ago (647,375 XP)

@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

ftrillo
ftrillo
1 week ago (12,140 XP)

@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 sign in or create an account to participate in this conversation.