From f30d7bf8f40d3802d296e9f93445e51f87d79d5b Mon Sep 17 00:00:00 2001 From: Luca Gambetta Date: Thu, 25 May 2017 20:23:33 +0200 Subject: Use the Collection created by the Engine diff --git a/src/Builder.php b/src/Builder.php index 15643f6..ebcdbb1 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -176,9 +176,8 @@ class Builder $perPage = $perPage ?: $this->model->getPerPage(); - $results = Collection::make($engine->map( - $rawResults = $engine->paginate($this, $perPage, $page), $this->model - )); + $rawResults = $engine->paginate($this, $perPage, $page); + $results = $engine->map($rawResults, $this->model); $paginator = (new LengthAwarePaginator($results, $engine->getTotalCount($rawResults), $perPage, $page, [ 'path' => Paginator::resolveCurrentPath(), diff --git a/src/Engines/Engine.php b/src/Engines/Engine.php index a52820b..fbd7b85 100644 --- a/src/Engines/Engine.php +++ b/src/Engines/Engine.php @@ -85,8 +85,6 @@ abstract class Engine */ public function get(Builder $builder) { - return Collection::make($this->map( - $this->search($builder), $builder->model - )); + return $this->map( $this->search($builder), $builder->model ); } }