From b9723879c99b73b40c86bc9ffc59b636dc73655f Mon Sep 17 00:00:00 2001 From: Marco Guidolin Date: Thu, 6 Apr 2023 09:48:49 +0000 Subject: [PATCH] ADD support for enum-casting of `type` field --- src/HasChildren.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/HasChildren.php b/src/HasChildren.php index ff651aa..a25475e 100644 --- a/src/HasChildren.php +++ b/src/HasChildren.php @@ -235,6 +235,11 @@ public function classFromAlias($aliasOrClass): string { $childTypes = $this->getChildTypes(); + // Handling Enum casting for `type` column + if ($aliasOrClass instanceof \UnitEnum) { + $aliasOrClass = $aliasOrClass->value; + } + if (isset($childTypes[$aliasOrClass])) { return $childTypes[$aliasOrClass]; }