Level 4
Hi Ozza,
The result you are getting is the expected result; please check https://laravel.com/docs/5.5/pagination#converting-results-to-json. Try to use
$collection->getCollection()->scroll_id;
Hope this helps.
Regards, Adrian
1 like
hello,
i have a collection which has a dd() like;
Pagination {#264 ▼
#total: 2324665
#lastPage: 232467
#items: Collection {#262 ▼
#items: array:10 [▶]
+"total": 2324665
+"max_score": null
+"took": 70
+"timed_out": false
+"scroll_id": "DnF1ZXJ5VGh◀"
+"shards": {#263 ▶}
}
#perPage: 10
#currentPage: 1
#path: "http://127.0.0.1:8000/scr"
#query: []
#fragment: null
#pageName: "page"
}
but returning the collection just gives me the array;
{
"current_page": 1,
"data": [],
"first_page_url": "http://127.0.0.1:8000/scr?page=1",
"from": 1,
"last_page": 232488,
"last_page_url": "http://127.0.0.1:8000/scr?page=232488",
"next_page_url": "http://127.0.0.1:8000/scr?page=2",
"path": "http://127.0.0.1:8000/scr",
"per_page": 10,
"prev_page_url": null,
"to": 10,
"total": 2324880
}
i need to get the "scroll_id" but i can't manage to. $collection->scroll_id returns an undefined property error. can someone help me?
Hi Ozza,
The result you are getting is the expected result; please check https://laravel.com/docs/5.5/pagination#converting-results-to-json. Try to use
$collection->getCollection()->scroll_id;
Hope this helps.
Regards, Adrian
Please or to participate in this conversation.