Skip to content

Commit

Permalink
Update OpenSearchEngine.php
Browse files Browse the repository at this point in the history
  • Loading branch information
zingimmick authored Aug 13, 2024
1 parent a90688a commit 002f9a1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Engines/OpenSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
/**
* Update the given model in the index.
*
* @param \Illuminate\Database\Eloquent\Collection $models
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $models
*/
public function update($models): void
{
Expand All @@ -44,16 +44,17 @@ public function update($models): void
$models->each->pushSoftDeleteMetadata();

Check failure on line 44 in src/Engines/OpenSearchEngine.php

View workflow job for this annotation

GitHub Actions / Lint / Lint

Call to an undefined method Illuminate\Support\HigherOrderCollectionProxy<string, Illuminate\Database\Eloquent\Model, Illuminate\Database\Eloquent\Collection<int, Illuminate\Database\Eloquent\Model>>::pushSoftDeleteMetadata().
}

$objects = $models->map(static function ($model): ?array {
$objects = $models->map(static function ($model): array {
$searchableData = $model->toSearchableArray();
if (empty($searchableData)) {
return null;
return [];
}

return array_merge($searchableData, $model->scoutMetadata(), [
$model->getScoutKeyName() => $model->getScoutKey(),
]);
})->filter()
})
->filter()
->values()
->all();

Expand All @@ -79,7 +80,7 @@ public function update($models): void
/**
* Remove the given model from the index.
*
* @param \Illuminate\Database\Eloquent\Collection $models
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $models
*/
public function delete($models): void
{
Expand Down Expand Up @@ -203,6 +204,8 @@ protected function performSearch(Builder $builder, array $options = []): mixed
* Pluck and return the primary keys of the given results.
*
* @param array{hits: mixed[]|null}|null $results
*
* @return \Illuminate\Support\Collection<int, int|string>
*/
public function mapIds($results): Collection
{
Expand All @@ -219,7 +222,7 @@ public function mapIds($results): Collection
* @param array{hits: mixed[]|null}|null $results
* @param \Illuminate\Database\Eloquent\Model $model
*
* @return \Illuminate\Database\Eloquent\Collection
* @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model>
*/
public function map(Builder $builder, $results, $model): mixed
{
Expand Down Expand Up @@ -249,6 +252,8 @@ public function map(Builder $builder, $results, $model): mixed
*
* @param array{hits: mixed[]|null}|null $results
* @param \Illuminate\Database\Eloquent\Model $model
*
* @return \Illuminate\Support\LazyCollection<int, \Illuminate\Database\Eloquent\Model>
*/
public function lazyMap(Builder $builder, $results, $model): LazyCollection
{
Expand Down

0 comments on commit 002f9a1

Please sign in to comment.