lengthawarepaginator gives keys on page 2

Solutions on MaxInterview for lengthawarepaginator gives keys on page 2 by the best coders in the world

showing results for - "lengthawarepaginator gives keys on page 2"
Federico
09 Jan 2018
1// On pages >= 2, the keys are returned since forPage returns an array with keys
2// To fix this, just chain values() method.
3$items_per_page = 10;
4$current_page = LengthAwarePaginator::resolveCurrentPage();
5$paginated_response = new LengthAwarePaginator(
6  	collect($items)->forPage($current_page, $items_per_page)->values(),
7  	count($items),
8  	$items_per_page,
9  	$current_page,
10  	['path' => url('api/portfolios')]
11);
12return response()->json($paginated_response);