Closed lukasmu closed 4 months ago
Thanks for the report @lukasmu! Apologies for the delayed response on this issue. I'd classify this as a bug -- it should definitely occur both ways. I think this is the case with some casts and not others. Let me update this and make sure its consistent across the board.
This has been now resolved in v3.6.2. Run composer update
and you're all set. Thanks!
It is possible to define the
$casts
property on models as explained here: https://ldaprecord.com/docs/core/v3/model-mutators/#attribute-castingHowever, the casting operation seems to work only when getting attributes, not when setting attributes. This is different from how casting works in Laravel's Eloquent and thus confused me.
Not sure if it's easily possible to add this, otherwise I would recommend to update the documentation.
Example:
What works:
What doesn't work: