diff --git a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php index 4a02fec5d2e8..c97c4033082e 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php @@ -205,10 +205,10 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole if ($types === ['*']) { $types = $this->model->newModelQuery()->distinct()->pluck($relation->getMorphType())->filter()->all(); + } - foreach ($types as &$type) { - $type = Relation::getMorphedModel($type) ?? $type; - } + foreach ($types as &$type) { + $type = Relation::getMorphedModel($type) ?? $type; } return $this->where(function ($query) use ($relation, $callback, $operator, $count, $types) {