laravel - How do you use setColumnAttribute with update()? -
I am attempting to strip non-numeric characters on an attribute before saving, but the new value is not saved is.
My model looks like this:
class model extends \ supernatural {public function set column attribute ($ value) {$ value = (int) preg_replace (' / [^ 0-9] / ',' ', $ Value); $ Return; }} If I add a dd ($ value) to it, then that method needs to be run, it is a dump. I update the model:
Model :: search ($ id) - & gt; Update ($ attributes); Why does not this save the value given by the setColumnAttribute method? What am I missing?
searching on a lucrative mutator I got it back to the value Instead of $ this- & gt; Attributes were included in the array. Extended in class model \ Supernatural {Public function set column attribute ($ value) {$ Value = (int) preg_replace ('/ [^ 0-9] /', '', $ value ); $ This- & gt; Attribute ['column'] = $ value; }}
Comments
Post a Comment