首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >子文件夹和分页中的Laravel

子文件夹和分页中的Laravel
EN

Stack Overflow用户
提问于 2016-01-27 22:10:55
回答 1查看 187关注 0票数 0

我将我的Laravel项目放在根文件夹的子(子)文件夹中,并在某些视图中使用simplePaginate()方法。在进行了一些搜索之后,我注意到使用了AbstractPaginator并提供了一个方法url(),该方法就在以后的某个地方,由从SimpleBootstrapThreePresenter调用的BootstrapThreeNextPreviousButtonRendererTrait调用。

我一直在搜索我的config/app.phphelpers.php文件,希望找到一些指向解决方案的东西。但目前还没有发现任何东西。

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

EN

回答 1

Stack Overflow用户

发布于 2016-01-27 23:09:38

我已经解决了修改BootstrapThreeNextPreviousButtonRendererTrait的问题。我知道我也可以修改AbstractPaginator,但因为我现在没有监督它的后果,所以我选择了根据我的需求定制特征,如下所示:

代码语言:javascript
复制
<?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');
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35039644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档