我有许多不同的方法可以插入和更新我的数据库,我希望能够在将用户输入插入到数据库之前
trim()
。 我知道在模型中,我可以做类似下面的事情,但是我不想为每个字段都这样做。 有没有一种通用的设置器,可适用于所有字段?public function setSomFieldAttribute($value) {
return $this->attributes['some_field'] = trim($value);
}