File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ private static function dataClass(string $postType): string
102102 if (null === $ classFQN ) {
103103 return static ::class;
104104 }
105-
105+
106106 if (! class_exists ($ classFQN )) {
107107 throw new RuntimeException (sprintf ('The class "%s" does not exist or is not autoloaded. ' , $ classFQN ));
108108 }
@@ -137,7 +137,9 @@ private function loadMeta(int $id): void
137137 $ meta = $ metaAttribute ->newInstance ();
138138 $ metaValue = $ meta ->getValue ($ id , $ property ->name , $ this ->metaPrefix ());
139139 if (null !== $ metaValue && null !== $ propertyTypeName ) {
140- if ('Spatie\LaravelData\Data ' === $ propertyTypeName || is_subclass_of ($ propertyTypeName , 'Spatie\LaravelData\Data ' )) {
140+ if (is_a ($ propertyTypeName , Data::class, true )) {
141+ $ metaValue = $ propertyTypeName ::from ($ metaValue );
142+ } elseif (is_a ($ propertyTypeName , \BackedEnum::class, true ) && (is_int ($ metaValue ) || is_string ($ metaValue ))) {
141143 $ metaValue = $ propertyTypeName ::from ($ metaValue );
142144 }
143145 $ property ->setValue ($ this , $ metaValue );
You can’t perform that action at this time.
0 commit comments