How is laravel paged data formatted?

if you use the paginate () method in the framework for paging, the outer layer of the data will be wrapped in an extra layer of paging data, for example:

{
    "total": 50,
    "per_page": 15,
    "current_page": 1,
    "last_page": 4,
    "next_page_url": "http://laravel.app?page=2",
    "prev_page_url": null,
    "from": 1,
    "to": 15,
    "data":[
        {
            // Result Object
        },
        {
            // Result Object
        }
    ]
}

how do I display paging data separately? For example:

"data":[
    {
        // Result Object
    },
    {
        // Result Object
    }
],
"page":    {
    "total": 50,
    "per_page": 15,
    "current_page": 1,
    "last_page": 4,
    "next_page_url": "http://laravel.app?page=2",
    "prev_page_url": null,
    "from": 1,
    "to": 15
}

I wrapped it myself to simplify the output, as follows:

  

manually process the return value of laravel before returning to the client, but this process is not very elegant. Let's see if we can communicate with the front end to solve your needs.

Menu