Skip to content

Commit 3276bac

Browse files
authored
Merge pull request #1158 from benargo/haswhere
Fix #1157 (Model::has() - ErrorException: Array to string conversion)
2 parents 1358e50 + 2263bc4 commit 3276bac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Jenssegers/Mongodb/Eloquent/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
150150
$relations = $query->pluck($relation->getHasCompareKey());
151151
$relationCount = array_count_values(array_map(function ($id) {
152152
return (string) $id; // Convert Back ObjectIds to Strings
153-
}, is_array($relations) ? $relations : $relations->toArray()));
153+
}, is_array($relations) ? $relations : $relations->flatten()->toArray()));
154154

155155
// Remove unwanted related objects based on the operator and count.
156156
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator) {

0 commit comments

Comments
 (0)