29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Pagination 310<br />

.<br />

1 Route::get('users', function () {<br />

2 return App\User::paginate();<br />

3 });<br />

The JSON from the paginator will include meta information such as total, current_page, last_-<br />

page, and more. The actual result objects will be available via the data key in the JSON array. Here<br />

is an example of the JSON created by returning a paginator instance from a route:<br />

Example Paginator JSON<br />

.<br />

1 {<br />

2 "total": 50,<br />

3 "per_page": 15,<br />

4 "current_page": 1,<br />

5 "last_page": 4,<br />

6 "next_page_url": "http://<strong>laravel</strong>.app?page=2",<br />

7 "prev_page_url": null,<br />

8 "from": 1,<br />

9 "to": 15,<br />

10 "data":[<br />

11 {<br />

12 // Result Object<br />

13 },<br />

14 {<br />

15 // Result Object<br />

16 }<br />

17 ]<br />

18 }

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!