Esempio n. 1
0
 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post())) {
         $upload = Up::getInstance();
         if ($upload) {
             $upload->on(Up::EVENT_AFTER_UPLOAD, ['backend\\components\\helpers\\Image', 'thumb']);
             $upload->on(Up::EVENT_AFTER_UPLOAD, ['backend\\components\\helpers\\Image', 'water'], null, false);
             $upload->save($model, 'cover', 'post');
         }
         if ($model->save()) {
             return $this->redirect(['index']);
         }
     }
     return $this->render('create', ['model' => $model]);
 }