dimanche 9 décembre 2018

Issue paginating an array of JSON objects in Laravel

Am working on a Laravel application whereby I hit an API and get a back an array of JSON objects. I need to paginate through the array and display 6 items per page on the view..

~ Please assist?

Code getting data from the API

     $lifePol = $this->global_Curl('api/v1/b2b/life/agent-policies' , $token)->data;

   dd($lifePol);

Sample data am getting from the API, contains 30 objects

array:30 [▼
  0 => {#302 ▼
    +"agent_no": "000"
    +"agent_code": "0000"
    +"policy_number": "************"
    +"plan": "*****************"
    +"status": "NO*************"
    +"effective_date": "2015-04-16 00:00:00"
  }
  1 => {#308 ▼
    +"agent_no": "000"
    +"agent_code": "0000"
    +"policy_number": "***************"
    +"plan": "****************"
    +"status": "AW**************"
    +"effective_date": "2014-03-31 00:00:00"
  }
   2 => {#308 ▼
    +"agent_no": "000"
    +"agent_code": "0000"
    +"policy_number": "***************"
    +"plan": "****************"
    +"status": "BT**************"
    +"effective_date": "2014-03-31 00:00:00"
  }
]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire