/**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->password) {
             $model->setPassword($model->password);
             $model->generateAuthKey();
         }
         $model->photoFile = UploadedFile::getInstance($model, 'photoFile');
         if ($model->photoFile && !$model->upload()) {
             Yii::$app->session->setFlash('error', Yii::t('app', 'Image not upload'));
             return $this->render('update', ['model' => $model]);
         }
         $model->setScenario('default');
         if ($model->save(false)) {
             User::changeRole($model->role, $model->getId());
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }