Пример #1
0
 /**
  * Creates a new Visi model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Visi();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $model->CREATED_BY = Yii::$app->user->identity->username;
             $image = $model->uploadImage();
             if ($model->save()) {
                 // upload only if valid uploaded file instance found
                 if ($image !== false) {
                     $path = $model->getImageFile();
                     $image->saveAs($path);
                 }
             }
         }
         return $this->redirect(['index']);
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }