Example #1
0
 /**
  * @return string|\yii\web\Response
  * @throws \yii\base\Exception
  */
 public function actionProjectManagerRequest()
 {
     $projectManager = new ProjectManager();
     $user = new User();
     $person = new Person();
     if (Yii::$app->request->post()) {
         $params = Yii::$app->request->post();
         $person->load($params);
         $user->load($params);
         $projectManager->load($params);
         if ($person->validate() && $user->validate() && $projectManager->validate()) {
             $user->password_hash = Yii::$app->getSecurity()->generatePasswordHash($params['User']['password_hash']);
             $person->save(false);
             $user->person_id = $person->id;
             $user->register();
             $projectManager->user_id = $user->id;
             $projectManager->save();
             Yii::$app->session->setFlash('success', 'Se envío un correo de confirmación. Por favor verifique su correo electrónico');
             return $this->refresh();
         } else {
             Yii::$app->session->setFlash('danger', 'Ocurrió un error al guardar. Vuelve a intentar');
         }
     }
     return $this->render('project-manager-request', ['projectManager' => $projectManager, 'user' => $user, 'person' => $person]);
 }
 /**
  * Creates a new ProjectManager model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ProjectManager();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }