Skip to content

Instantly share code, notes, and snippets.

@mohamadaliakbari
Last active December 3, 2018 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamadaliakbari/62f8d127a1488c89e8bb04ed0dfa0b59 to your computer and use it in GitHub Desktop.
Save mohamadaliakbari/62f8d127a1488c89e8bb04ed0dfa0b59 to your computer and use it in GitHub Desktop.
Paginate Elastiquent searchByQuery with getAggregations
$entities = Entity::searchByQuery($query, $aggregation_criteria, NULL, 36, ($request->get('page', 1) - 1) * 36);
$aggregations = $entities->getAggregations();
$entities = new LengthAwarePaginator($entities, $entities->totalHits(), 36, LengthAwarePaginator::resolveCurrentPage(), array('path' => LengthAwarePaginator::resolveCurrentPath()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment