我尝试为用户add
创建一个日志系统,并在添加新用户时通知管理员,并要求他允许新用户登录。
任何人都知道是否有可用的插件?或者如何将这些数据保存在两个表中。
我试过这个
public function add() {
$user = $this->Users->newEntity();
$log = $this->Logs->newEntity();
if ($this->request->is('post')) {
$user = $this->Users->patchEntity($user, $this->request->data);
$user->criado_por = $this->Auth->user('nome');
$user->modificado_por = $this->Auth->user('nome');
$user->userstatus = 'waiting for permitions';
$log->date = date::now();
$log->newuser = $user->name;
$log->whocreate = $this->Auth->User('name');
if ($this->Users->save($user)) {
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
}
}
$this->set(compact('user'));
$this->set('_serialize', ['user']);
}