/**
  * @return string|\yii\web\Response
  */
 public function actionIndex()
 {
     $accountModel = new AccountForm();
     $accountModel->setUser(Yii::$app->user->identity);
     $model = new MultiModel(['models' => ['account' => $accountModel, 'profile' => Yii::$app->user->identity->userProfile]]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-success'], 'body' => Yii::t('frontend', 'Your account has been successfully saved')]);
         return $this->refresh();
     }
     return $this->render('index', ['model' => $model]);
 }
Ejemplo n.º 2
0
 public function actionProfile()
 {
     $profile = Yii::$app->user->identity->userProfile;
     $domain = Yii::$app->user->identity->domain;
     if ($domain == null) {
         $model = new MultiModel(['models' => ['profile' => $profile]]);
     } else {
         $model = new MultiModel(['models' => ['profile' => $profile, 'domain' => $domain]]);
     }
     if ($model->load($_POST) && $model->save()) {
         Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-success'], 'body' => Yii::t('backend', 'Your account has been successfully saved', [], $model->getmodel('profile')->locale)]);
         return $this->refresh();
     }
     return $this->render('profile', ['model' => $model]);
 }