-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Weird. It seems like the cast is being ignored. You could use hooks to verify if the values ( |
Beta Was this translation helpful? Give feedback.
-
After some experimentation, I found a solution that worked for me. Instead of relying on $casts to handle the penempatan attribute as an array, I manually added an accessor and mutator in my model:
I also removed the $casts entry for penempatan. This way, the attribute is properly stored as JSON in the database and retrieved as an array in the application. This approach gives me more control over the serialization process, especially when $casts doesn’t work as expected. Just make sure to validate the data format before saving to avoid encoding/decoding issues. |
Beta Was this translation helpful? Give feedback.
After some experimentation, I found a solution that worked for me. Instead of relying on $casts to handle the penempatan attribute as an array, I manually added an accessor and mutator in my model:
I also removed the $casts entry for penempatan. This way, the attribute is properly stored as JSON in the database and retrieved as an array in the application.
This approach gives me more control over the serialization process, especially when $casts doesn’t work as expected. Just make sure to …