My controller:
$customers = Customer::paginate();
return new CustomerResource($customers);
My CustomerResource:
public function toArray($request)
{
return parent::toArray($request);
}
According to docs, it has mentioned that it api will return related data under meta key as
{
"data": [
{},{},{}...
],
"links":{
"first": "http://example.com/pagination?page=1",
"last": "http://example.com/pagination?page=1",
"prev": null,
"next": null
},
"meta":{
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "http://example.com/pagination",
"per_page": 15,
"to": 10,
"total": 10
}
}
But, I am receiving data as:
{
"current_page": 1,
"data": [
{},{},{}
],
"first_page_url": "http://inventory.test/api/customers?page=1",
"from": 1,
"last_page": 14,
"last_page_url": "http://inventory.test/api/customers?page=14",
"links": [
{},{}
],
"next_page_url": "http://inventory.test/api/customers?page=2",
"path": "http://inventory.test/api/customers",
"per_page": 15,
"prev_page_url": null,
"to": 15,
"total": 200
}
Am I missing something??