From 03654809bddcfb924ddaef74590d0483909847b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liudas=20=C5=A0umskas?= Date: Wed, 11 Dec 2024 18:16:49 +0200 Subject: [PATCH] Fixed Enum usage in whereHasMorph condition when morph attribute casting (#53839) * Fixed Enum using in whereHasMorph condition * Fixed StyleCI * Update QueriesRelationships.php * Update QueriesRelationships.php --------- Co-authored-by: Liudas Co-authored-by: Taylor Otwell --- .../Database/Eloquent/Concerns/QueriesRelationships.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php index 20f377bc3fe..894e7525846 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php @@ -16,6 +16,8 @@ use Illuminate\Support\Str; use InvalidArgumentException; +use function Illuminate\Support\enum_value; + /** @mixin \Illuminate\Database\Eloquent\Builder */ trait QueriesRelationships { @@ -229,7 +231,10 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole $types = (array) $types; if ($types === ['*']) { - $types = $this->model->newModelQuery()->distinct()->pluck($relation->getMorphType())->filter()->all(); + $types = $this->model->newModelQuery()->distinct()->pluck($relation->getMorphType()) + ->filter() + ->map(fn ($item) => enum_value($item)) + ->all(); } if (empty($types)) {