master

laravel/framework

Last updated at: 29/12/2023 09:24

PaginationServiceProvider.php

TLDR

This file is the PaginationServiceProvider class in the Illuminate\Pagination namespace. It is used in the Illuminate Pagination package to provide pagination services for Laravel applications.

Methods

boot

This method is responsible for bootstrapping any application services. It loads the views from the specified directory and publishes them if the application is running in console mode.

register

This method registers the service provider by resolving the PaginationState class using the Laravel application.

<?php

namespace Illuminate\Pagination;

use Illuminate\Support\ServiceProvider;

class PaginationServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->loadViewsFrom(__DIR__.'/resources/views', 'pagination');

        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__.'/resources/views' => $this->app->resourcePath('views/vendor/pagination'),
            ], 'laravel-pagination');
        }
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        PaginationState::resolveUsing($this->app);
    }
}