Render simplePaginate without a last page

simplePaginate omits the total and last_page. The Vue footer uses previous and next only.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/simple-paginate-vue.md
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.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

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.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

php
$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.

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

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.