Sep 12, 2016
3
Level 5
Pagination not showing on last page with one result
I may be missing something really obvious but I'm trying to use pagination for the first time and it works unless the last page has one result. Then it doesn't show pagination at all (not a style issue; no ul.pagination on the page).
The query:
$posts = Post::orderBy('updated_at', 'desc')->paginate(5);
return view('index', compact('posts'));
View (also tried with render method):
{{ $posts->links() }}
I have six Post records. The first page displays five records with the pagination links rendered as expected. Clicking on page 2 shows the sixth record but no pagination, so I have to use the browser back button to get back to the first page.
If however I change it to paginate(4), it works fine.
Is this expected behavior?
Level 1
3 likes
Please or to participate in this conversation.