/**
  * Updates an existing Profile model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate()
 {
     PermissionHelpers::requireUpgradeTo('Paid');
     if ($model = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one()) {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view']);
         } else {
             return $this->render('update', ['model' => $model]);
         }
     } else {
         throw new NotFoundHttpException('Нет такого профиля');
     }
 }
예제 #2
0
 /**
  * Updates an existing Profile model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate()
 {
     //        $model = $this->findModel($id);
     //
     //        if ($model->load(Yii::$app->request->post()) && $model->save()) {
     //            return $this->redirect(['view', 'id' => $model->id]);
     //        } else {
     //            return $this->render('update', [
     //                'model' => $model,
     //            ]);
     //        }
     PermissionHelpers::requireUpgradeTo('Paid');
     if ($model = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one()) {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view']);
         } else {
             return $this->render('update', ['model' => $model]);
         }
     } else {
         throw new NotFoundHttpException('No such profile');
     }
 }