示例#1
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#2
0
 /**
  * @inheritDoc
  */
 public function actionCreate()
 {
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Helper::invalidate();
         Yii::$app->session->setFlash('info', '菜单[ ' . $model->name . ' ]添加成功!');
         return $this->redirect(['index']);
     } else {
         $model->parent_name = Yii::$app->request->get('parentName');
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
示例#3
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionAdd()
 {
     //菜单权限检测
     Yii::$app->util->adminAuth() ? '' : $this->redirect('/admin/login');
     $model = new Menu();
     if ($model->load(Yii::$app->request->post())) {
         $model->create_time = time();
         if ($model->save()) {
             return $this->redirect(['index']);
         } else {
             return $this->render('add', ['model' => $model]);
         }
     } else {
         $data = $model->menu();
         $parent = [];
         foreach ($data as $v) {
             if ($v['parent_id'] == 0) {
                 $parent[$v['id']] = $v['menu_name'];
             }
         }
         $parent[0] = '顶级菜单';
         return $this->render('add', ['model' => $model, 'parent' => $parent]);
     }
 }
示例#4
0
 /**
  * 快捷菜单新建
  * @return  {[type]}                          [description]
  * @version 1.0      2016-01-25T12:24:11+0800     * @author cnzhangxl@foxmail.com
  */
 public function actionMyCreate()
 {
     $model = new Menu(['scenario' => 'my_create']);
     $model->mg_id = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Menu::removeMyMenuCache();
         return $this->redirect(['my']);
     } else {
         return $this->render('my_create', ['model' => $model]);
     }
 }