/** * 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(); $request = Yii::$app->request; $allMenu = $model::find()->where(['uid' => Yii::$app->user->getId()])->count(); if ($allMenu >= 200) { UHelper::alert('每个账号最多建200个菜单', 'error'); return $this->redirect(['index']); } else { UHelper::alert('你已建有' . $allMenu . '个菜单,每个账号最多可建立200个菜单'); } if ($request->isPost) { $model->load($request->post()); $model->images = JquploadHelper::jqformat(); $model->share = Json::encode($request->post('share')); if ($model->save()) { UHelper::alert('新增成功!', 'success'); return $this->redirect(['index']); } } else { if ($request->get('type') == 'addchild') { $model->parentId = $request->get('id'); } $model->images = [['label' => '导航图标'], ['label' => '按钮图标'], ['label' => '分享图片']]; $model->share = [['分享标题', 'share[title]', '', '分享出去的标题'], ['分享描述', 'share[desc]', '', '分享出去的描述']]; $model->is_open = 1; return $this->render('create', ['model' => $model, 'plugArray' => $this->plugList(), 'menuList' => Menu::findlist()]); } }
/** * 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(); $request = Yii::$app->request; $plugModel = new Plug(); $plugList = $plugModel::find(); UHelper::output($plugList); if ($request->isPost) { $model->load($request->post()); $model->menu_images = JquploadHelper::jqformat(); if ($model->save()) { return $this->redirect(['update', 'id' => $model->menu_id]); } } else { return $this->render('create', ['model' => $model]); } }