i'm developing an api with Laravel and DingoAPI which returns the message threads of the user with pagination.
$threads = Thread::forUser($currentUserId)->latest('updated_at')->simplePaginate(1);
return API::response()->array($threads);
and i get this kind of response :
{
"per_page": 1,
"current_page": 1,
"next_page_url": "http://my.app/api/messages?page=2",
"prev_page_url": null,
"from": 1,
"to": 1,
"data": [
{
"id": 1,
"subject": null,
"created_at": "2016-03-18 12:33:38",
"updated_at": "2016-03-18 12:33:38",
"deleted_at": null
}
]
}
What can i do to remove some field of the response ? i just need data and next_page_url …
i tried this way :
$array_response = [
'next_page_url' => $threads['next_page_url'],
'data' => $threads['data']
];
but only null values are returned. I guess Dingo Api is doing some work behind the scene…