Beispiel #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]);
     }
 }
Beispiel #2
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionCreate()
 {
     $model = new Menu();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'i' => $model->w_id]);
     } else {
         if (!$this->wid) {
             throw new NotFoundHttpException("请先选择要操作的公众号");
         }
         $wechat = Wechat::find()->where(['id' => $this->wid])->one();
         if (!$wechat) {
             throw new NotFoundHttpException("没有此公众号信息");
         }
         $model->type = Menu::TYPE_URL;
         return $this->render('create', ['model' => $model, 'wechat' => $wechat]);
     }
 }