Liviu Hariton
PHP developer
Laravel 10 - use Bootstrap 5 for pagination styling
In your /app/Providers/AppServiceProvider.php
class, you need to add the code below inside the boot()
method to support the Bootstrap pagination styling:
Paginator::useBootstrap();
Complete code:
<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
/*
* You can use here a specific version of Bootstrap CSS
* By default, useBootstrap() loads the version 4
* Other options:
* useBootstrapThree() loads the version 3
* useBootstrapFour() loads the version 4
* useBootstrapFive() loads the version 5
*/
Paginator::useBootstrapFive();
}
}
You want to be able to customize the pagination’s HTML template, you first need to publish the required assets by running the following command in your terminal:
$ php artisan vendor:publish
and from the presented list choose laravel-pagination
– all the required resources will be copied to the resources/views/vendor/pagination
folder from where you can freely edit them.