#Casting attributes to Enum fails and returns `Attempt to read property "name" on string`

2 messages · Page 1 of 1 (latest)

opaque ether
#

When I check the error inside my unit tests I see this:

Attempt to read property "name" on string

  at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:1179
    1175▕     protected function getStorableEnumValue($value)
    1176▕     {
    1177▕         return $value instanceof BackedEnum
    1178▕                 ? $value->value
  ➜ 1179▕                 : $value->name;
    1180▕     }

Does this mean the enum is seen as a string instead of an actual backed enum?

#

When I add this to the getStorableEnumValue method:

        if (!$value instanceof BackedEnum) {
            dd($value);
        }

it dumps a string but I can't find the reason why it should pass a string there.