Skip to content

Commit 0365480

Browse files
OutsidazLiudastaylorotwell
authored
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 <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 9f66103 commit 0365480

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Illuminate\Support\Str;
1717
use InvalidArgumentException;
1818

19+
use function Illuminate\Support\enum_value;
20+
1921
/** @mixin \Illuminate\Database\Eloquent\Builder */
2022
trait QueriesRelationships
2123
{
@@ -229,7 +231,10 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole
229231
$types = (array) $types;
230232

231233
if ($types === ['*']) {
232-
$types = $this->model->newModelQuery()->distinct()->pluck($relation->getMorphType())->filter()->all();
234+
$types = $this->model->newModelQuery()->distinct()->pluck($relation->getMorphType())
235+
->filter()
236+
->map(fn ($item) => enum_value($item))
237+
->all();
233238
}
234239

235240
if (empty($types)) {

0 commit comments

Comments
 (0)