Example #1
0
 /**
  * Updates an existing Banner 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()) && $model->save()) {
         foreach (Property::getLanguages() as $lang) {
             $file = UploadedFile::getInstanceByName('image_' . $lang);
             if (!is_null($file)) {
                 ImageManager::addBannerImage($model->id, $file, $lang);
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }