/** * 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; }
/** * 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.'); } }