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

krunal05's avatar

Laravel 8 - Pagination not showing numbers

I am trying to do a pagination and it works. But in the pagination I am only getting

« Previous Next »

How to do pagination with laravel so that i can see number pagination

< 1 2 3 >


$users = User::where('id', '!=', Auth::id())->paginate(2);

        return view('users.index',
                           ['users' => $users]
        );






In the blade

{{ $users->links() }}
0 likes
19 replies
krunal05's avatar

Hello, just aboove pagination i am printing total

{{ $users->total() }}
        {{ $users->links() }}

Output

7 « Previous Next »

krunal05's avatar
$users = User::where('id', '!=', Auth::id())->paginate(2);
        dd(count($users));

Here i am getting 2 because I am using paginate(2)

laracoft's avatar

ok, I'm a bit stumped here, but I would check the actual rendered HTML to confirm if the page numbers are showing or not, to rule out CSS issues.

laracoft's avatar
laracoft
Best Answer
Level 27

@krunal05 At which timing? I also just saw that L8 ->links() is tailwind CSS by default

jlrdw's avatar

@krunal05 you can use any CSS you want with pagination and write any custom template you need.

It's just styling for the pagination links (css).

Reference from documentation:

https://laravel.com/docs/8.x/pagination#customizing-the-pagination-view

The templates are at

vendor\laravel\framework\src\Illuminate\Pagination\resources\views

Once published you can modify as needed, you can even write your own. But all of this is covered in the documentation.

Back in version 6 I had to tweak a template. See:

https://laracasts.com/discuss/channels/guides/paginator-another-episode

Also laravel has an API documentation:

https://laravel.com/api/8.x/

kawser's avatar

Try this {{$users->links('pagination::bootstrap-4')}}

3 likes
shortlyportly's avatar

Hi.

In case someone else is struggling with this.

I had the same issue and fixed it by running.

php artisan vendor:publish --tag=laravel-pagination

This exports the views into your resources/views/vendor/pagination directory. I didn't make any other changes and the page numbers showed up.

3 likes
mahbubrn's avatar

@shortlyportly Its work for me. Also I have to call the pagination view file after calling this artisan command.

php artisan vendor:publish --tag=laravel-pagination

{{ $list->links('vendor.pagination.default') }}

Please or to participate in this conversation.