app/config/view.php: 'pagination' => 'pagination.slider', 在vendor/laravel/framework/src/Illuminate/Pagination/Presenter.php 添加2個函數 public function getIndex($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->currentPage <= 1) { return $this->getDisabledTextWrapper($text); } $url = $this->paginator->getUrl(1); return $this->getPageLinkWrapper($url, $text, 'prev'); } public function getLast($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->currentPage >= $this->lastPage) { return $this->getDisabledTextWrapper($text); } $url = $this->paginator->getUrl($this->lastPage); return $this->getPageLinkWrapper($url, $text, 'next'); } 在app/views/pagination/slider.php: <?php $presenter = new Illuminate\Pagination\BootstrapPresenter($paginator); ?> <?php if ($paginator->getLastPage() > 1): ?> <div class="pagination"> <ul> <?php /* How many pages need to be shown before and after the current page */ $showBeforeAndAfter = 3; /* Current Page */ $currentPage = $paginator->getCurrentPage(); $lastPage = $paginator->getLastPage(); /* Check if the pages before and after the current really exist */ $start = $currentPage - $showBeforeAndAfter; /* Check if first page in pagination goes below 1, and substract that from $showBeforeAndAfter var so the pagination won't start with page 0 or below */ if($start < 1){ $diff = $start - 1; $start = $currentPage - ($showBeforeAndAfter + $diff); } $end = $currentPage + $showBeforeAndAfter; if($end > $lastPage){ $diff = $end - $lastPage; $end = $end - $diff; } echo $presenter->getIndex('< 首頁'); echo $presenter->getPrevious('< 上一頁'); echo $presenter->getPageRange($start, $end); echo $presenter->getNext('下一頁 >'); echo $presenter->getLast('最後一頁 >'); ?> </ul> </div> <?php endif; ?> app/controllers/admin/PageController.php: public function index(){ return \View::make('admin.pages.index')->with('pages',Page::orderBy('created_at')->paginate(5)); } app/views/admin/pages/index.blade.php 在列表尾部添加: {{ $pages->links() }}