'Show page numbers as navigation in Laravel pagination
I ma using Laravel 9 and it renders previous,next button for pagination. How could I change it to page numbers.
It shows : < Previous , Next >
What I want is: < 1 2 3 4 >
In controller I got:
public function index(Request $request)
{
$users = User::orderBY('id','desc')->paginate(2)->withQueryString();
return view('panel.users.index', ['users' => $users]);
}
In blade template I got:
{{ $users->links() }}
Solution 1:[1]
By default Laravel 9 used Tailwind CSS. To use these views instead of the default Tailwind views, you may call the paginator's useBootstrap method within the boot method of your App\Providers\AppServiceProvider class:
use Illuminate\Pagination\Paginator;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Paginator::useBootstrapFive();
Paginator::useBootstrapFour();
}
official docs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sarwar Ahmed |
