Commit 3276bac2 authored by Jens Segers's avatar Jens Segers Committed by GitHub

Merge pull request #1158 from benargo/haswhere

Fix #1157 (Model::has() - ErrorException: Array to string conversion)
parents 1358e504 2263bc4f
......@@ -150,7 +150,7 @@ class Builder extends EloquentBuilder
$relations = $query->pluck($relation->getHasCompareKey());
$relationCount = array_count_values(array_map(function ($id) {
return (string) $id; // Convert Back ObjectIds to Strings
}, is_array($relations) ? $relations : $relations->toArray()));
}, is_array($relations) ? $relations : $relations->flatten()->toArray()));
// Remove unwanted related objects based on the operator and count.
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment