コード例 #1
0
ファイル: UsersController.php プロジェクト: enpitut/cynts
 /**
  * Add method
  *
  * @return \Cake\Network\Response|void
  */
 public function add()
 {
     $user = $this->Users->newEntity();
     if ($this->request->is('post')) {
         $user = $this->Users->patchEntity($user, $this->request->data);
         $user->set('password', User::hashPassword($user->get('password')));
         $user->set('created_at', time());
         $user->set('updated_at', time());
         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']);
 }