1
我正在使用laravel 4.2,由於某種原因,我需要訪問我認爲失敗的lastPage
屬性。這是我的控制器分頁時的代碼。如何從結果集訪問受保護的lastPage屬性
$products = Product::where('status', '=', 'available')->paginate(20);
下面是我的視圖文件var_dump($products)
的一部分,我需要知道如何訪問它的正確方法。
protected 'total' => int 10491
protected 'hasMore' => null
protected 'perPage' => int 20
protected 'currentPage' => int 1
protected 'lastPage' => int 525
protected 'from' => int 1
protected 'to' => int 20
如果我沒有錯,你實際上打算調用非保護方法' - > getLastPage()',它將返回'lastPage'的值。 *編輯*我沒有錯,你可以在[這裏的文檔]找到它(http://laravel.com/docs/4.2/pagination)。 Cntrl + f「getLastPage」 – Ohgodwhy
@Ohgodwhy謝謝。太棒了。我的確使用'$ products-> getLastPage()'來訪問它。你能否在評論中回答它,以便我可以將其標記爲已接受的答案。 – KristCont