示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Merchant::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'merchant_name', $this->merchant_name])->andFilterWhere(['like', 'wechatid', $this->wechatid])->andFilterWhere(['like', 'appid', $this->appid])->andFilterWhere(['like', 'secret', $this->secret])->andFilterWhere(['like', 'token', $this->token])->andFilterWhere(['like', 'access_token', $this->access_token])->andFilterWhere(['like', 'encodekey', $this->encodekey]);
     return $dataProvider;
 }
示例#2
0
 public function setOptions()
 {
     $request = Yii::$app->getRequest();
     $merchant = $request->get('merchant');
     $info = Merchant::find()->where(['id' => $merchant])->asArray()->one();
     if (!$info) {
         throw new NotFoundHttpException('The requested wechat does not exist.');
     }
     $session = Yii::$app->session;
     $session->set('merchant.app_id', $info['appid']);
     $session->set('merchant.secret', $info['secret']);
     $session->set('merchant.token', $info['token']);
     $session->set('merchant.id', $merchant);
 }
示例#3
0
 /**
  * Updates an existing Menu model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'i' => $model->merchant_id]);
     } else {
         $merchant = Merchant::find()->where(['id' => $this->merchant_id])->one();
         if (!$merchant) {
             throw new NotFoundHttpException("没有此公众号信息");
         }
         $model->type = Menu::TYPE_URL;
         return $this->render('update', ['model' => $model, 'merchant' => $merchant]);
     }
 }
示例#4
0
 /**
  * Finds the Merchant model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Merchant the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Merchant::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }