Is there way i can rename the data key in laravel collection results? At the moment this
DB::table('contracts AS C')->paginate(1)
returns
{
"current_page": 1,
"data": [
{
"id": 191,
"buyer": "John",
"provider": "Jane"
}
],
"from": 1,
"last_page": 1,
"next_page_url": "",
"path": "",
"per_page": 1,
"prev_page_url": null,
"to": 1,
"total": 1
}
What i would like is this
{
"current_page": 1,
"parties": [
{
"id": 191,
"buyer": "John",
"provider": "Jane"
}
],
"from": 1,
"last_page": 1,
"next_page_url": "",
"path": "",
"per_page": 1,
"prev_page_url": null,
"to": 1,
"total": 1
}
The challenge here changing the data key to parties