Example #1
0
 /**
  * @param string|array $condition
  * @return BaseActiveQuery
  */
 protected function buildActiveQuery($condition)
 {
     /** @var BaseActiveQuery $query */
     $query = $this->model->find()->andWhere($condition);
     if ($this->pagination instanceof Pagination) {
         $query->offset($this->pagination->offset);
         $query->limit($this->pagination->limit);
     }
     return $query;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Model::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['doc_id' => $this->doc_id]);
     $query->andFilterWhere(['like', 'zipcode', $this->zipcode]);
     return $dataProvider;
 }