Skip to content

Commit

Permalink
Merge pull request #2 from jhoff/bump_scout_5.0
Browse files Browse the repository at this point in the history
Update to scout 5.0
  • Loading branch information
olsgreen authored Oct 12, 2018
2 parents 62d0c1b + cddb81f commit a3e5240
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=7.0",
"laravel/scout": "^4.0"
"laravel/scout": "^5.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
25 changes: 13 additions & 12 deletions src/DatabaseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -28,7 +28,7 @@ public function __construct(DatabaseManager $database)

/**
* Get a base query builder.
*
*
* @return \Illuminate\Database\Query\Builder
*/
protected function query()
Expand All @@ -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);
Expand All @@ -73,7 +73,7 @@ public function update($models)
*
* @param \Illuminate\Database\Eloquent\Collection $models
* @return void
*/
*/
public function delete($models)
{
$index = $models->first()->searchableAs();
Expand Down Expand Up @@ -120,7 +120,7 @@ protected function performSearch(Builder $builder, array $options = [])
}
});
}

/**
* Perform the given search on the engine.
*
Expand All @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -203,4 +204,4 @@ public function mapIds($results)
{
return $results['results']->pluck('objectID')->values();
}
}
}

0 comments on commit a3e5240

Please sign in to comment.