/** * Adding new category. * @return string|\yii\web\Response */ public function actionNewCategory() { if (User::can(Rbac::PERM_CREATE_CATEGORY)) { $model = new Category(); $model->visible = 1; $model->sort = 0; if ($model->load(Yii::$app->request->post()) && $model->save()) { Log::info('Category added', $model->id, __METHOD__); $this->success(Yii::t('podium/flash', 'New category has been created.')); return $this->redirect(['admin/categories']); } return $this->render('category', ['model' => $model, 'categories' => Category::find()->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all()]); } else { $this->error(Yii::t('podium/flash', 'You are not allowed to perform this action.')); return $this->redirect(['admin/categories']); } }
/** * Adding new category. * @return string|\yii\web\Response */ public function actionNewCategory() { $model = new Category(); $model->visible = 1; $model->sort = 0; if ($model->load(Yii::$app->request->post()) && $model->save()) { Log::info('Category added', !empty($model->id) ? $model->id : '', __METHOD__); $this->success('New category has been created.'); return $this->redirect(['admin/categories']); } else { return $this->render('category', ['model' => $model, 'categories' => Category::find()->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all()]); } }