/** * Creates a new AuthItem model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new AuthItem(); if ($model->load(Yii::$app->request->post())) { $model->rule_name = !empty($model->rule_name) ? $model->rule_name : NULL; $model->save(); return $this->redirect(['view', 'id' => $model->name]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new AuthItem model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (Yii::$app->user->can('createAuthItem')) { $model = new AuthItem(); if ($model->load(Yii::$app->request->post())) { $model->created_at = time(); $model->updated_at = time(); $model->save(); return $this->redirect(['view', 'id' => $model->name]); } else { return $this->render('create', ['model' => $model]); } } else { throw new ForbiddenHttpException(); } }