我工作的一个API,我被困在分页 首先,我稍后发送基于用户通过限制值仅前10条记录,我应该送next
10条记录Laravel 5.3 API分页
所以我这样做
//search Drivers
public function getSearchList($limit)
{
//dd($limit);
$drivers = Driver::paginate($limit)
->select('id','first_name','last_name','phone_number','registration_id')
->orderBy('first_name', 'asc')
->get();
return Response::json([
'data' => $drivers->all()
]);
}
但我在请求http://localhost:8000/api/v1/search-list/10
BadMethodCallException in Macroable.php line 74:
Method select does not exist.
我的事情我不是得到错误牛逼这样做是正确
期待着急需帮助
谢谢
非常感谢你们一如既往的出色,如果数据只有120个,请告诉我如何显示消息'not found',如果他们输入555这样的东西,谢谢 –
@MrRobot just add像'if(count($ drivers)== 0){//没有数据}' –
,我想发送下10个不是最后发送的10个值 –