From 63d7db2111d353ddca8588b6096680b0f5a60096 Mon Sep 17 00:00:00 2001 From: Olivier Mourlevat Date: Fri, 29 Jan 2021 14:08:55 +0100 Subject: [PATCH] fix MeiliSearch\Search\SearchResult as array fix "Cannot use object of type MeiliSearch\Search\SearchResult as array" --- src/Engines/MeilisearchEngine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Engines/MeilisearchEngine.php b/src/Engines/MeilisearchEngine.php index 5402985..33d816a 100644 --- a/src/Engines/MeilisearchEngine.php +++ b/src/Engines/MeilisearchEngine.php @@ -172,11 +172,11 @@ public function mapIds($results) */ public function map(Builder $builder, $results, $model) { - if (is_null($results) || 0 === count($results['hits'])) { + if (is_null($results) || 0 === $results->getHitsCount()) { return $model->newCollection(); } - $objectIds = collect($results['hits'])->pluck($model->getKeyName())->values()->all(); + $objectIds = collect($results->getHits())->pluck($model->getKeyName())->values()->all(); $objectIdPositions = array_flip($objectIds); return $model->getScoutModelsByIds(