DEV Community

Ibrar Hussain
Ibrar Hussain

Posted on

Use Bootstrap Pagination with Laravel 8

If you are using Laravel 8 for your application and want to use bootstrap pagination instead of the default one. Then we need to add the Paginator::useBootstrap(); in boot function in AppServiceProvider file.

You AppServiceProvider file should look like this:

<?php

namespace App\Providers;

use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Paginator::useBootstrap();
    }
}
Enter fullscreen mode Exit fullscreen mode

After this, your application pagination will use bootstrap pagination look and feel.

Top comments (2)

Collapse
 
laramate profile image
Chris Wolf

Worth mentioning / Update for Laravel 9:
The Paginator-Facade offers multiple methods to select different templates and even bootstrap versions, e.g.:
Paginator::useBootstrapFour()
Paginator::useBootstrapFive()

You can select a template on an individual basis, like so:
{{ $invoices->links('pagination::simple-bootstrap-5') }}

Collapse
 
ibrarturi profile image
Ibrar Hussain

Thank you @crslp for mentioning that