Ad

Paginator Not Working In Laravel 5.2 After Upgrading From Laravel 4.2

- 1 answer

My paginator::make() is not working in laravel 5.2 .I also used Length Aware Paginator , nothing works,

        $packages = Paginator::make($packages, $totalPackages, $perPage);

what is the replacement of that in laravel 5.2

Ad

Answer

Nothing is changed in laravel 5.2 from 5.1. It works exactly like this.

lets say you've table name User and you want to paginate user list

In Controller

$users = User::all()->paginate(10);  
$users->setPath('users'); //Customise Page Url
return view('users',compact('users'));

The setPath method allows you to customize the URI used by the paginator when generating links. For example, if you want the paginator to generate links like http://example.com/custom/url?page=N, you should pass custom/url to the setPath method:

View

{!! $users->render() !!} 
Ad
source: stackoverflow.com
Ad