Ifrit's avatar
Level 2

Pagination not showing post

I've got a query that I'm paginating and the issue I'm having is that if my data is less then what my paginate has then it doesn't show.

So for example if I have 9 posts and my ->paginate(10) then it doesn't show, but if I change to ->paginate(5) then it shows

Here is my code

$posts = DB::connection('blog')
                        ->table('posts')
                        ->join('authors', 'posts.author_id', '=', 'authors.id')
                        ->where('posts.author_id', $author_id)
                        ->where('posts.published', 1)
                        ->select(
                            'posts.id as id',
                            'posts.title as post_title',
                            'authors.title as author',
                            'posts.body as content'
                        )
                        ->paginate(10);
0 likes
2 replies
jlrdw's avatar

That's normal behavior not to show unless you have more than one page.

Ifrit's avatar
Level 2

What do I do then? Because it's possible that an author might not have 10 posts

Please or to participate in this conversation.