我将我的Laravel项目放在根文件夹的子(子)文件夹中,并在某些视图中使用simplePaginate()方法。在进行了一些搜索之后,我注意到使用了AbstractPaginator并提供了一个方法url(),该方法就在以后的某个地方,由从SimpleBootstrapThreePresenter调用的BootstrapThreeNextPreviousButtonRendererTrait调用。
我一直在搜索我的config/app.php和helpers.php文件,希望找到一些指向解决方案的东西。但目前还没有发现任何东西。
如何将Laravel (5.1)设置为将我的子文件夹结构与分页类一起使用?
发布于 2016-01-27 23:09:38
我已经解决了修改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 = '«')
{
// 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 = '»')
{
// 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');
}
}https://stackoverflow.com/questions/35039644
复制相似问题