-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Description
请教下,不知道是我设置不对还是什么问题
举个例子,比如:
数据库有字段 num new_num
在model是这么设置根据num设置new_num
public function setNewNumAttr($value, $data)
{
return $data['num'] + 1;
}
然后在entity这么设置,获取前台修改的num
public function save($data){
$this->num = $data['num'];
$this->new_num = $data['new_num'] ;
return $res = $this->save();
}
在controller这么设置,前端就传了num值过来
$data = input();
$user = UserEntity::find(1);
$user->save($data);
我代码是从3.0移植过来的,在3.0上这样是没问题的
在4.0要改成$this->force()->save();才会保存到数据库,然后还产生个问题,加了force()后,update_time不自动写入了
Metadata
Metadata
Assignees
Labels
No labels