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() }}
How many users are in your database?
@krunal05 Can you confirm with a dd(count($users)) before returning the view?
What you you get in
$users->total();
Hello, just aboove pagination i am printing total
{{ $users->total() }}
{{ $users->links() }}
Output
7
« Previous Next »
$users = User::where('id', '!=', Auth::id())->paginate(2);
dd(count($users));
Here i am getting 2 because I am using paginate(2)
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.
@krunal05 At which timing?
I also just saw that L8 ->links() is tailwind CSS by default
@krunal05 you can use bootstrap pagination if you want.
@jlrdw how do i do that in laravel 8?
Thank @michaloravec . I really didn't want to include the Tailwindcss as i was not familiar with it.
Try this
{{$users->links('pagination::bootstrap-4')}}
Hello, I am having the same issue with pagination.
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.
@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.