/** * 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(['index', 'i' => $model->merchant_id]); } else { if (!$this->merchant_id) { throw new NotFoundHttpException("请先选择要操作的公众号"); } $merchant = Merchant::find()->where(['id' => $this->merchant_id])->one(); if (!$merchant) { throw new NotFoundHttpException("没有此公众号信息"); } $model->type = Menu::TYPE_URL; return $this->render('create', ['model' => $model, 'merchant' => $merchant]); } }