0

我将以下代码与 Laravel Responder 一起使用:

 return responder()->success(Service::paginate(5), ServiceTransformer::class)->respond();

Laravel Responder 是一个用于构建 API 响应的包。我得到了这样的回应:

    "status": 200,
    "success": true,
    "data": [
        {
            "value": 1,
            "label": "Angular"
        },
        {
            "value": 2,
            "label": "PHP"
        },
        {
            "value": 3,
            "label": "Drupal"
        }
    ],
    "pagination": {
        "count": 3,
        "total": 4,
        "perPage": 3,
        "currentPage": 1,
        "totalPages": 2,
        "links": {
            "next": "http://127.0.0.1:8000/api/service/list?perPage=3&page=2"
        }
    }

我想在元中包含分页,有没有办法做到这一点?例子

meta:  { 
"pagination": {
        "count": 3,
        "total": 4,
        "perPage": 3,
        "currentPage": 1,
        "totalPages": 2,
        "links": {
            "next": "http://127.0.0.1:8000/api/service/list?perPage=3&page=2"
        }
}

有没有办法做到这一点?

4

0 回答 0