Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

lengthawarepaginator gives keys on page 2

// On pages >= 2, the keys are returned since forPage returns an array with keys
// To fix this, just chain values() method.
$items_per_page = 10;
$current_page = LengthAwarePaginator::resolveCurrentPage();
$paginated_response = new LengthAwarePaginator(
  	collect($items)->forPage($current_page, $items_per_page)->values(),
  	count($items),
  	$items_per_page,
  	$current_page,
  	['path' => url('api/portfolios')]
);
return response()->json($paginated_response);
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #lengthawarepaginator #keys #page
ADD COMMENT
Topic
Name
1+5 =