Laravel 5 拉维尔5号+;帕金酸丁戈皮酯

Laravel 5 拉维尔5号+;帕金酸丁戈皮酯,laravel-5,pagination,dingo-api,Laravel 5,Pagination,Dingo Api,我正在用Laravel和DingoAPI开发一个api,它返回用户分页的消息线程 $threads = Thread::forUser($currentUserId)->latest('updated_at')->simplePaginate(1); return API::response()->array($threads); 我得到了这样的回应: { "per_page": 1, "current_page": 1, "next_page_url": "ht

我正在用Laravel和DingoAPI开发一个api,它返回用户分页的消息线程

$threads = Thread::forUser($currentUserId)->latest('updated_at')->simplePaginate(1);
return API::response()->array($threads);
我得到了这样的回应:

{
  "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
    }
  ]
}
如何删除响应的某些字段?我只需要数据和下一页的url

我试着这样做:

$array_response = [
        'next_page_url' => $threads['next_page_url'],
        'data' => $threads['data']
        ];
但只返回空值。 我猜野狗Api在幕后做了一些工作…

试试这个

$threads = Thread::forUser($currentUserId)->latest('updated_at')->simplePaginate(1);
$arrayResponse = json_decode(API::response()->array($threads));
$arrayResponseEdited = [
        'next_page_url' => $arrayResponse['next_page_url'],
        'data' => $arrayResponse['data']
];

return arrayResponseEdited;