AccessorsはDBから呼び出す際に、modelでget.${ColumnName}.Attributeとしましたが、Mutatorは、DBに挿入する際に、set.${ColumnName}.Attributeで指定します。
Model: User.php
public function setNameAttribute($value){
$this->attributes['name'] = strtoupper($value);
}
Route
Route::get('/setname', function(){
$user = User::find(1);
$user->name = "william";
$user->save();
});
mysql> select * from users;
+—-+———+————+———-+—————-+————+———————+————+
| id | name | email | password | remember_token | created_at | updated_at | country_id |
+—-+———+————+———-+—————-+————+———————+————+
| 1 | WILLIAM | john@gmail | 1234 | NULL | NULL | 2019-12-11 03:31:16 | 0 |
+—-+———+————+———-+—————-+————+———————+————+
1 row in set (0.00 sec)
getとsetは飽きるほどやりましたね。