public function __set($name, $values) { if ($this->hasConvertAttribute($name)) { $mode = $this->convert_attributes[$name]; if ($mode == 'json') { $this->attributes[$name] = json_encode($values); return; } } return is_callable(['parent', '__set']) ? parent::__set($name, $values) : null; }
/** * Magic Method for setting Aware attributes. * ignores unchanged attibutes delegates to Eloquent * * @param string $key * @param string|num|bool|etc $value * @return void */ public function __set($key, $value) { // only update an attribute if there's a change if (!array_key_exists($key, $this->attributes) || $value !== $this->{$key}) { parent::__set($key, $value); } }