/** * Creates a new Nav model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Nav(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Nav model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (!$this->is_access('navigator/create')) { Yii::$app->session->setFlash('error', $this->errorInfo); return $this->redirect($this->redirectUrl); } $model = new Nav(); if ($model->load(Yii::$app->request->post()) && $model->save()) { \backend\models\UserLog::addData('nav', $model->id, "新增导航[{$model->name}]", 'add'); Yii::$app->session->setFlash('success', '添加成功'); return $this->redirect(['index']); } else { Yii::$app->view->params['meta_title'] = '添加导航栏'; return $this->render('create', ['model' => $model]); } }