0

I use the following code with Laravel Responder:

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

Laravel Responder is a package for building API responses. And I get this response:

    "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"
        }
    }

I want to include pagination in meta, is there a way to do this? example

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"
        }
}

Is there a way to achieve this?

Mindru Ion
  • 373
  • 5
  • 19
  • `responder` is not a built-in Laravel function, so it'd be helpful if you indicated which library you're using there. – ceejayoz Nov 26 '19 at 14:01
  • This one? https://github.com/flugger/laravel-responder Look into a response decorator, if so. https://github.com/flugger/laravel-responder#decorating-response – ceejayoz Nov 26 '19 at 14:08
  • thanks man, sorry for disturbing – Mindru Ion Nov 26 '19 at 14:15

0 Answers0