如何在Laravel 5中使用分页? [英] How to use pagination in laravel 5?
本文介绍了如何在Laravel 5中使用分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
am试图将我的laravel4应用程序移植到laravel 5.在以前的版本中,我可以使用以下方法来生成分页网址.
am trying to port my laravel4 application to laravel 5 . In the previous version i could use the following method for generating pagination urls .
在控制器中:
$this->data['pages']= Page::whereIn('area_id', $suburbs)->where('score','>','0')->orderBy('score','desc')->paginate(12);
并在与视图共享数据数组后,我可以使用用户
and after sharing the data array with the view, i could user
视图中:
{{$pages->links()}}
在laravel 5中,这样做会导致以下错误
In laravel 5 the doing that results in following error
ErrorException in AbstractPaginator.php line 445:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Support\Collection' does not have a method 'links'
不确定我在这里缺少什么,有人可以帮忙吗?
not sure what i am missing here, can somebody help ?
推荐答案
在Laravel 5中,没有方法链接"可以尝试
In Laravel 5 there is no method "links" you can try this
{!! $pages->render() !!}
这篇关于如何在Laravel 5中使用分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文