Ejemplo n.º 1
0
 /**
  * Updates an existing AssignRole 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())) {
         $old_parents = $model->parents;
         if ($model->save()) {
             MyModel::updateChildParents($model, $old_parents);
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Updates an existing Skill 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);
     $model->scenario = 'update';
     if ($model->load(Yii::$app->request->post())) {
         $oldImg = $model->image;
         $old_parents = $model->parents;
         MyModel::upload($model);
         if ($model->save()) {
             MyModel::updateParents($model);
             MyModel::updateChildParents($model, $old_parents);
             if ($oldImg != $model->image && $model->image != '') {
                 MyModel::deleteFile($oldImg);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
         return $this->render('update', ['model' => $model]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }