2016-09-28 95 views
0

我的分頁不工作在最新版本的laravel 5.3, 我已經使用了分頁方法,我只是想知道爲什麼當前頁面方法不存在。Laravel 5.3方法currentpage不存在

public function getIndex($author =null) 
 
\t { 
 
\t \t if(!is_null($author)){ 
 
\t \t \t $quote_author = Author::where('name', $author)->first(); 
 
\t \t \t if($quote_author){ 
 
\t \t \t \t $quotes = $quote_author->quotes()->orderBy('created_at','desc')->paginate(6); 
 
\t \t \t } 
 
\t \t \t else{ 
 
\t \t \t \t $quotes = Quote::orderBy('created_at','desc')->paginate(6); 
 
\t \t \t } 
 
\t \t \t return view('index',['quotes' => $quotes]); 
 
\t \t } 
 
\t \t $quotes = Quote::all(); 
 
\t \t return view('index',['quotes' => $quotes]); 
 
\t }
<div class="pagination"> 
 
\t \t @if($quotes->currentpage() !==1) 
 
\t \t \t <a href="{{ $quotes->previousPageUrl() }}"><span class="fa fa-caret-left"></span></a> 
 
\t \t @endif 
 
\t \t @if($quotes->currentpage() !== $quotes->lastpage() && $quotes->hasPages()) 
 
\t \t \t <a href="{{ $quotes->nextPageUrl() }}"><span class="fa fa-caret-right"></span></a> 
 
\t \t @endif 
 
</div>

+0

我覺得這個方法叫做currentPage() –

回答

1

方法名是currentPage()大寫P.

您可以瞭解其他paginator methods in the documentation

此外,在$author爲空的情況下,您將回退到未分頁的Quote::all()。將其轉換爲Quote::paginate(6),以便$quotes將始終是分頁符的實例。

0

方法名稱currentPage() p必須是大寫字母

0

currentPage()是在Paginator類中的方法。當你使用all()時,你會得到一個Collection的實例。

我想你想要的是$quotes = Quote::paginate($n);其中$n是每頁所需的結果數量。