People searching “Laravel simplePaginate Vue” copy a footer that prints last_page and then the control is blank. simplePaginate does not count the table. The pagination guide compares the three objects. This page is the footer that matches this one.
TL;DR
- simplePaginate omits the total and last_page.
- The Vue footer uses previous and next only.
- Do not compute “page 2 of undefined” in the template.
- Do not run a second
count()query in the controller “just for the label” and think you kept simple pagination.
The fix#
$posts = Post::query()->orderBy('id')->simplePaginate(12)->withQueryString();You get data, current_page, prev_page_url, and next_page_url. You do not get total or last_page.
<Link v-if="posts.prev_page_url" :href="posts.prev_page_url">Previous</Link>
<Link v-if="posts.next_page_url" :href="posts.next_page_url">Next</Link>What to avoid#
Gotcha
Do not compute “page 2 of undefined” in the template. If the product needs the count, use paginate and pay for the count. Do not run a second count() query in the controller “just for the label” and think you kept simple pagination.
FAQ#
How do I render simplePaginate without a last page?
simplePaginate omits the total and last_page. The Vue footer uses previous and next only.
What goes wrong with Laravel simplePaginate Vue?
Many developers copy a footer that prints last_page and then the control is blank. Do not compute "page 2 of undefined" in the template.



