CakePHP 3.0将数据保存到表中

时间:2015-10-23 18:44:09

标签: cakephp notifications

我尝试为用户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']);
}

1 个答案:

答案 0 :(得分:1)

这是CakePHP的通知插件:Notifier