How can I introduce pagination in meta with laravel responder?

140 Views Asked by At

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?

0

There are 0 best solutions below