Exemplo n.º 1
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     $model->created_by = Yii::$app->user->id;
     $task = Yii::$app->request->post('task', 'save');
     if ($model->load(Yii::$app->request->post())) {
         //$model = $this->uploadFoto($model);
         if ($model->uploadFoto() === false) {
             Yii::$app->session->setFlash('error', 'Ошибка загрузки фото');
         }
         $model->save();
         Yii::$app->session->setFlash('success', 'Saved');
         if ($task == 'apply') {
             return $this->redirect(['update', 'id' => $model->id]);
         } else {
             return $this->redirect(['index']);
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }