-
Notifications
You must be signed in to change notification settings - Fork 107
Description
@lindyhopchris Are there any concrete plans on tackling this in the foreseeable future?
I'm currently struggling using the searched hook to add/update a top-level meta field when having paginated results.
e.g. I currently have some response with top-level pagination meta "magically" (to my current knowledge) added:
{
"meta": {
"page": {
"current-page": 1,
"per-page": 100,
"from": 1,
"to": 100,
"total": 21781,
"last-page": 218
}
},
"links": {},
"data": {}
}Without finding the time yet to delve into the code, it seems that data in a LengthAwarePaginator somehow result in pagination information being included in the top level meta.
Now my problem is, that I didn't find an obvious way to get my hands on that pagination meta data within the searched hook to extend it with some custom data.
My current implementation looks something like this and loses the page metadata:
public function searched($paginatedData)
{
$meta = ['some' => 'data'];
return $this->reply()
->content(
$paginatedData,
[], // links
$meta // <-- how can I add my own meta without overriding the pagination meta?
);
}What I would like to have is something like this (note the "some": "data" next to page):
{
"meta": {
"some": "data",
"page": {
"current-page": 1,
"per-page": 100,
"from": 1,
"to": 100,
"total": 21781,
"last-page": 218
}
},
"links": {},
"data": {}
}Originally posted by @tsterker in #225 (comment)