【问题标题】:Laravel in a subfolder and paginationLaravel 在子文件夹和分页中
【发布时间】:2016-05-04 12:56:32
【问题描述】:

我的 Laravel 项目位于我的根文件夹的子(子)文件夹中,并且在某些视图中使用 simplePaginate() 方法。经过一番搜索,我注意到AbstractPaginator 被使用并提供了一个方法url(),该方法位于由BootstrapThreeNextPreviousButtonRendererTrait 调用的某个地方,该方法从SimpleBootstrapThreePresenter 调用。

我一直在我的config/app.phphelpers.php 文件中搜索以找到指向解决方案的内容。但是还没有找到任何东西。

如何设置 Laravel (5.1) 以将我的子文件夹结构与分页类一起使用?

【问题讨论】:

    标签: php laravel configuration pagination subdirectory


    【解决方案1】:

    我已经通过修改BootstrapThreeNextPreviousButtonRendererTrait 解决了这个问题。我知道我也可以修改AbstractPaginator,但由于我现在没有监督这样做的后果,我选择根据我的需要调整特征,如下所示:

    <?php
    
    namespace Illuminate\Pagination;
    
    use Illuminate\Support\Facades\Request;
    
    trait BootstrapThreeNextPreviousButtonRendererTrait
    {
        /**
         * Get the previous page pagination element.
         *
         * @param  string  $text
         * @return string
         */
        public function getPreviousButton($text = '&laquo;')
        {
            // If the current page is less than or equal to one, it means we can't go any
            // further back in the pages, so we will render a disabled previous button
            // when that is the case. Otherwise, we will give it an active "status".
            if ($this->paginator->currentPage() <= 1) {
                return $this->getDisabledTextWrapper($text);
            }
    
            $url = url() . '/' . Request::path() . '?page=' . ($this->paginator->currentPage() - 1);
            //Laravel shipped code disabled because of an installation in a sub-sub folder.
            //$url = $this->paginator->url(
            //    $this->paginator->currentPage() - 1
            //);
    
            return $this->getPageLinkWrapper($url, $text, 'prev');
        }
    
        /**
         * Get the next page pagination element.
         *
         * @param  string  $text
         * @return string
         */
        public function getNextButton($text = '&raquo;')
        {
            // If the current page is greater than or equal to the last page, it means we
            // can't go any further into the pages, as we're already on this last page
            // that is available, so we will make it the "next" link style disabled.
            if (! $this->paginator->hasMorePages()) {
                return $this->getDisabledTextWrapper($text);
            }
    
            $url = url() . '/' . Request::path() . '?page=' . ($this->paginator->currentPage() + 1);
            //Laravel shipped code disabled because of an installation in a sub-sub folder.
            //$url = $this->paginator->url($this->paginator->currentPage() + 1);
    
            return $this->getPageLinkWrapper($url, $text, 'next');
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2014-07-10
      • 2023-02-04
      • 1970-01-01
      • 1970-01-01
      • 2015-02-08
      • 2019-03-28
      • 2015-05-15
      • 1970-01-01
      • 2018-02-25
      相关资源
      最近更新 更多