Laravel 通过服务提供者来自定义分页样式

需求介绍

laravel默认了分页,实现非常优雅,但有时候会遇到修改默认的样式,比如我要将默认的

    修改为

      解决办法切入点

      Laravel自带的分页链接样式由IlluminatePaginationBootstrapThreePresenter的render方法生成,我们在此方法上做文章即可实现。

      创建重写render方法的类

      创建文件:App/Presenters/PagiationPresenter

      hasPages()) {
                  return new HtmlString(sprintf(
                      '
        %s %s %s
      ', $this->getPreviousButton(), $this->getLinks(), $this->getNextButton() )); } return ''; } }

      创建服务提供者PaginationServiceProvider

      将服务提供者添加到config/app.php

      'providers' => [
      
              /*
               * Laravel Framework Service Providers...
               */
               ...
              App\Providers\PaginationServiceProvider::class,
          ],

      讨论群

      QQ : 339803849 (欢迎加入)

      实例源码

      我的开源博客Moell Blog

你可能感兴趣的:(分页,laravel,php)