MorphTo fields won't work when morph type column uses php Enum with casts #5306
-
Description:MorphTo field doesn't seem to work well when a model has the type column casted as a php Enum. Detailed steps to reproduce the issue on a fresh Nova installation:Have an enum defining the models that can be contactable.
Have a polymorphic relation to these contactable models
Define a nova resource for this Model
Then you get:
I guess contactable_type is not expected to be casted as an Enum... but why not? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want to do this, that would mean that every usage of You can set/limit the possible type by using |
Beta Was this translation helpful? Give feedback.
If you want to do this, that would mean that every usage of
contactable_type
need to pass the Enum instance while Nova POST requests can only send in astring
. This is currently not supported add just complicates the usage without any advantage.You can set/limit the possible type by using
MorphTo::types()
as suggested in the documentation: https://nova.laravel.com/docs/4.0/resources/relationships.html#morphto