Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sauravs012's avatar

Laravel pagination URL without query string

I've used this article for pagination: https://usingphp.com/post/make-custom-pagination-url-in-laravel-without-query-strings

There demo is: https://usingphp.com/posts/wordpress

But, there are only next and previous pagination links, but i want all numbers of pagination. Can someone please help me with that

0 likes
7 replies
MichalOravec's avatar

Use this package for that

https://github.com/michaloravec/laravel-paginateroute

This package adds the paginate route method to support pagination via custom routes instead of query strings. This also allows for easily translatable pagination routes ex. (normal) /news/page/2, /novinky/stranka/2 or (dash) /news/page-2, /novinky/stranka-2. It is also possible to remove the word "page" from the URL ex. (simple) /news/2

sauravs012's avatar

I think it will make my website slow... That's why I have created everything custom

coder2's avatar

Why not use the pagination method? Example:

$posts = Post::query()
	->orderBy("id", "DESC")
	->paginate(20);

And blade template, use links:

@foreach($posts as $post)
	{{ $post->name }}
@endforeach

{{ $posts->links() }}
1 like
jlrdw's avatar

You can write a pagination template anyway you want.

Please or to participate in this conversation.