/**
  * Creates a new Profile model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Profile();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Profile model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Profile();
     $model->user_id = \Yii::$app->user->identity->id;
     if ($already_exists = RecordHelpers::userHas('profile')) {
         return $this->render('view', ['model' => $this->findModel($already_exists)]);
     } elseif ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemple #3
0
 public function actionProfile()
 {
     $model_profile = new Profile();
     $model_pass = new ChangePassword();
     $user = new User();
     $info = $user->getUserInfo(Yii::$app->user->getId());
     $message = "";
     if ($model_profile->load(Yii::$app->request->post()) && $model_profile->validate()) {
         foreach ($model_profile as $key => $value) {
             if ($model_profile->{$key}) {
                 $info->setAttribute($key, Html::encode($model_profile->{$key}));
             }
         }
         $info->update();
         $message = "Changes saved";
     }
     if ($model_pass->load(Yii::$app->request->post()) && $model_pass->validate()) {
         if ($model_pass->new_password == $model_pass->new_password_rep) {
             $info->setAttribute('password_hash', Yii::$app->security->generatePasswordHash(Html::encode($model_pass->new_password)));
             $info->update();
             $message = "Changes saved";
         }
     }
     $model = new Job();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['../job/view', 'id' => (string) $model->_id]);
     }
     return $this->render('profile', ['model_profile' => $model_profile, 'model_pass' => $model_pass, 'info' => $info, 'message' => $message, 'model' => $model]);
 }