From cddb81f4d5c4f46d964555b3eeba7ff8d55b204b Mon Sep 17 00:00:00 2001 From: Jordan Hoff Date: Fri, 12 Oct 2018 09:50:21 -0500 Subject: [PATCH] Update to scout 5.0 --- composer.json | 2 +- src/DatabaseEngine.php | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 3ab7fe2..153c762 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=7.0", - "laravel/scout": "^4.0" + "laravel/scout": "^5.0" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/src/DatabaseEngine.php b/src/DatabaseEngine.php index 6747997..1d36ee6 100644 --- a/src/DatabaseEngine.php +++ b/src/DatabaseEngine.php @@ -11,14 +11,14 @@ class DatabaseEngine extends Engine { /** * Database connection. - * + * * @var \Illuminate\Database\DatabaseManager */ protected $database; /** * Spin up a new instance of the engine. - * + * * @param DatabaseManager $database */ public function __construct(DatabaseManager $database) @@ -28,7 +28,7 @@ public function __construct(DatabaseManager $database) /** * Get a base query builder. - * + * * @return \Illuminate\Database\Query\Builder */ protected function query() @@ -53,15 +53,15 @@ public function update($models) } return [ - 'objectID' => $model->getKey(), - 'index' => $model->searchableAs(), + 'objectID' => $model->getKey(), + 'index' => $model->searchableAs(), 'entry' => json_encode($array), ]; }) ->filter() ->each(function($record) { $attributes = [ - 'index' => $record['index'], + 'index' => $record['index'], 'objectID' => $record['objectID'] ]; $this->query()->updateOrInsert($attributes, $record); @@ -73,7 +73,7 @@ public function update($models) * * @param \Illuminate\Database\Eloquent\Collection $models * @return void - */ + */ public function delete($models) { $index = $models->first()->searchableAs(); @@ -120,7 +120,7 @@ protected function performSearch(Builder $builder, array $options = []) } }); } - + /** * Perform the given search on the engine. * @@ -141,7 +141,7 @@ public function search(Builder $builder) * @param int $perPage * @param int $page * @return mixed - */ + */ public function paginate(Builder $builder, $perPage, $page) { $results = $this->performSearch($builder) @@ -152,15 +152,16 @@ public function paginate(Builder $builder, $perPage, $page) return ['results' => $results, 'total' => $total]; } - + /** * Map the given results to instances of the given model. * + * @param \Laravel\Scout\Builder $builder * @param mixed $results * @param \Illuminate\Database\Eloquent\Model $model * @return \Illuminate\Database\Eloquent\Collection */ - public function map($results, $model) + public function map(Builder $builder, $results, $model) { if ($results['total'] === 0) { return Collection::make(); @@ -203,4 +204,4 @@ public function mapIds($results) { return $results['results']->pluck('objectID')->values(); } -} \ No newline at end of file +}