php - Laravel Reading from API with Limits and Displaying onto View with Pagination -


hi little confused on how can read api page item limited display , paginate them onto view pagination, such when click on pagination link on view view next page, display able show based on data api?

here scenario of doing, have api link this: http://localhost:8888/api/v1/categories, display json list of categories limited 5 per page following. , next page http://localhost:8888/api/v1/categories?page=2.

    {   "data": [     {       "id": 1,       "name": "arts & entertainment",       "status": true,       "created_at": "2015-09-20 16:19:15",       "updated_at": "2015-09-25 12:58:52"     },     {       "id": 2,       "name": "travel",       "status": true,       "created_at": "2015-09-20 16:19:23",       "updated_at": "2015-09-25 12:59:02"     },     {       "id": 3,       "name": "child development",       "status": true,       "created_at": "2015-09-20 16:19:28",       "updated_at": "2015-09-25 12:59:07"     },     {       "id": 4,       "name": "computers / internet",       "status": true,       "created_at": "2015-09-20 16:19:44",       "updated_at": "2015-09-25 12:59:27"     }   ],   "paginator": {     "total_count": 15,     "total_pages": 3,     "current_page": 1,     "limit": 5   } } 

i using laravel 5.1, , guzzlehttp read data so:

public function index()     {         $client = new client(['base_uri' => 'http://localhost:8888/api/v1/']);         $response = $client->get('categories')->getbody();         $content = json_decode($response->getcontents());          // how continue pagination , display onto view pagination function?         return view('categories', ['content' => $content->data]);     } 

views:

<div class="container">     <ul>     @foreach($content $value)         <li>{{ $value->name }}</li>     @endforeach     </ul> </div> 

thanks in advance taking time through.


Comments