From 5170a9d7564ce6d2424e021c7561138c9950c76d Mon Sep 17 00:00:00 2001 From: Achyut Neupane Date: Thu, 2 Jan 2025 23:14:45 +0545 Subject: [PATCH] ReflectionClass for enum detection --- .../src/Commands/Concerns/CanReadModelSchemas.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/support/src/Commands/Concerns/CanReadModelSchemas.php b/packages/support/src/Commands/Concerns/CanReadModelSchemas.php index 955d8eafba..fd680b2f41 100644 --- a/packages/support/src/Commands/Concerns/CanReadModelSchemas.php +++ b/packages/support/src/Commands/Concerns/CanReadModelSchemas.php @@ -9,7 +9,6 @@ use Illuminate\Support\Str; use ReflectionClass; use ReflectionException; -use function Illuminate\Support\enum_value; trait CanReadModelSchemas { @@ -234,6 +233,14 @@ public function getRecordTitleAttribute(): ?string protected function getEnumCasts($model) { $casts = app($model)->getCasts(); - return array_filter($casts, fn ($cast) => enum_exists($cast)); + return array_filter($casts, function ($cast) { + + if (class_exists($cast)) { + $reflection = new \ReflectionClass($cast); + return $reflection->isEnum(); + } + + return false; + }); } }