当当前登录的用户创建/添加配置文件时,我试图将值“1”保存到我的用户表的“profile_created”字段中,我当前的实现不会更改此值,有什么建议吗?提前致谢。
当前配置文件添加代码:
public function add() {
if ($this->request->is('post')) {
$this->Profile->create();
$this->request->data['Profile']['user_id'] = $this->Auth->user('id');
// code implemented below
$this->loadModel('User');
$data = array(
'Profile' => array('user_id' => $this->Auth->user('id')),
'User' => array('profile_created' => '1'),
);
if ($this->Profile->saveAssociated($this->request->data)) {
$this->Session->setFlash(__('Your account profile has been created'));
$this->redirect(array('controller' => 'events', 'action' => 'index'));
} else {
$this->Session->setFlash(__('Your account profile could not be saved. Please, try again.'));
}
}
}