How to export table with enum column?
Hello! I have column that maps to some enum. When I try to use
formatStateUsing
:
I receive error
Is it possivle to fix it?6 Replies
Can you not cast the lang attribute on the model as the enum?
I can, but it's not convenient in other places. Anyway I can use
state()
and then just get what I want, but I think there should be some way with formatStateUsing
If the enum doesn’t work in all places, then I kinda feel it misses the point of using an enum.
The whole point of an enum is to normalize the value or case across the app.
It's what I do. Values in DB are the same as in the my enum
As they should be. That’s the point of the cast. What I’m getting at is that the enum shouldn’t be more or less complicated depending on where it is accessed.
And if it is, something in the app is not using the enum in the way it is supposed to be used.
Of course I’m saying this from a fundamental pov, I have no insight into your actual app logic or use case based on what’s been provided. 🙂
Hi i had the same problem and i solved it this way:
``