1To define a mutator, define a setFooAttribute method on your model where Foo
2 is the "studly" cased name of the column you wish to access. So, again,
3lets define a mutator for the first_name attribute. This mutator will
4be automatically called when we attempt to set the value of the first_name
5attribute on the model:
6
7class User extends Model
8{
9 public function setFirstNameAttribute($value)
10 {
11 $this->attributes['first_name'] = strtolower($value);
12 }
13}
1Methods you can try :
21. $model->getAttributes()['name']; //worked for me
32. $model->getOriginal('name');
43. $this->attributes['name'];