Skip to content

Instantly share code, notes, and snippets.

@0xgdr
Last active September 2, 2019 04:29
Show Gist options
  • Select an option

  • Save 0xgdr/b4e583f7a02030f29b971b1ae7f2a593 to your computer and use it in GitHub Desktop.

Select an option

Save 0xgdr/b4e583f7a02030f29b971b1ae7f2a593 to your computer and use it in GitHub Desktop.
Laravel manual paginator example.
// use Illuminate\Pagination\LengthAwarePaginator;
$data = collect($matrixReportService->matrixReport($request));
$perPage = 5;
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$currentPageSearchResults = $data->slice(($currentPage - 1) * $perPage, $perPage)->all();
$entries = new LengthAwarePaginator($currentPageSearchResults, count($data), $perPage);
return response()->json($data, 200) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment