How to use pagination in laravel 5?

Sojan Jose picture Sojan Jose · Jan 16, 2015 · Viewed 75.9k times · Source

am trying to port my laravel4 application to laravel 5 . In the previous version i could use the following method for generating pagination urls .

In controller:

$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

In views :

{{$pages->links()}}

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 ?

Answer

Alasu Paul Sabrin picture Alasu Paul Sabrin · Jan 16, 2015

In Laravel 5 there is no method "links" you can try this

{!! $pages->render() !!}