2016-01-27 3 views
0

У меня есть проект Laravel в суб (sub) папке из моей корневой папки, и я использую метод simplePaginate() в некоторых представлениях. После небольшого поиска я указал, что используется AbstractPaginator и предоставляет метод url(), который находится где-то по дороге, вызванной BootstrapThreeNextPreviousButtonRendererTrait, которая вызывается из SimpleBootstrapThreePresenter.Laravel в подпапках и разбивке на страницы

Я искал в своем файле config/app.php и helpers.php, чтобы найти что-то, что указывает на решение. Но пока ничего не нашли.

Как настроить Laravel (5.1) для использования моей структуры подпапки с классом разбиения на страницы?

ответ

0

Я решил это изменить 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'); 
    } 
}