From 6b41765dfa922d2f297dcf286d92a2fe8dd47581 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 11 Feb 2020 23:14:52 +0100 Subject: [PATCH] Fix Trying to get property 'value' of non-object (#9) This trick solve an issue on eloquent creation. --- src/Enum.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Enum.php b/src/Enum.php index 24f8c02..9c68252 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -24,11 +24,11 @@ public function attachEnum($class) ->rules('required', new EnumValue($class, false)) ->resolveUsing( function ($enum) { - return $enum->value; + return $enum ? $enum->value : null; }) ->displayUsing( function ($enum) { - return $enum->description; + return $enum ? $enum->description : null; }); }