jeudi 1 mars 2018

Convert attribute to string before saving (during update) (5.4)

I've had a look at serialization after the model is loaded from the database using protected $casts, but we have a slightly different situation. What I'm trying to figure out is how to use serialize() function to save model' attributes instead of json_encode and not having much luck. Using accessors does not work since it's only for the accessing the data, not for doing post-load-from-database conversion. Are there any examples of how this can be done? The only one I can think of is the subscription to the event, but this is going to be messy.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oy2PLH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire