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);