Skip to content

Commit

Permalink
🧽 Styling.
Browse files Browse the repository at this point in the history
  • Loading branch information
olsgreen committed Apr 14, 2024
1 parent 7342457 commit b07a688
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
30 changes: 17 additions & 13 deletions src/ElasticsearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Elasticsearch\Client;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\LazyCollection;
use Laravel\Scout\Builder;
use Laravel\Scout\Engines\Engine;
use Illuminate\Support\LazyCollection;

class ElasticsearchEngine extends Engine
{
Expand Down Expand Up @@ -249,9 +249,10 @@ public function map(Builder $builder, $results, $model)
/**
* Map the given results to instances of the given model via a lazy collection.
*
* @param \Laravel\Scout\Builder $builder
* @param mixed $results
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Laravel\Scout\Builder $builder
* @param mixed $results
* @param \Illuminate\Database\Eloquent\Model $model
*
* @return \Illuminate\Support\LazyCollection
*/
public function lazyMap(Builder $builder, $results, $model)
Expand All @@ -265,19 +266,21 @@ public function lazyMap(Builder $builder, $results, $model)
$objectIdPositions = array_flip($objectIds);

return $model->queryScoutModelsByIds(
$builder, $objectIds
)->cursor()->filter(function ($model) use ($objectIds) {
return in_array($model->getScoutKey(), $objectIds);
})->sortBy(function ($model) use ($objectIdPositions) {
return $objectIdPositions[$model->getScoutKey()];
})->values();
$builder,
$objectIds
)->cursor()->filter(function ($model) use ($objectIds) {
return in_array($model->getScoutKey(), $objectIds);
})->sortBy(function ($model) use ($objectIdPositions) {
return $objectIdPositions[$model->getScoutKey()];
})->values();
}

/**
* Create a search index.
*
* @param string $name
* @param array $options
* @param string $name
* @param array $options
*
* @return mixed
*/
public function createIndex($name, array $options = [])
Expand All @@ -288,7 +291,8 @@ public function createIndex($name, array $options = [])
/**
* Delete a search index.
*
* @param string $name
* @param string $name
*
* @return mixed
*/
public function deleteIndex($name)
Expand Down
2 changes: 1 addition & 1 deletion tests/ElasticsearchEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use BoxedCode\Laravel\Scout\ElasticsearchEngine;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\LazyCollection;
use Laravel\Scout\Builder;
use Mockery;
use Tests\Fixtures\TestModel;
use Illuminate\Support\LazyCollection;

class ElasticsearchEngineTest extends AbstractTestCase
{
Expand Down

0 comments on commit b07a688

Please sign in to comment.