Beispiel #1
0
 public function search($params)
 {
     $query = Events::find();
     $pageSize = isset($params['per-page']) ? intval($params['per-page']) : 10;
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     //$query->joinWith('user');
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'time' => $this->time, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Events::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(['id' => $this->id, 'date' => $this->date, 'author_id' => $this->author_id, 'publish_date' => $this->publish_date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'picture_path', $this->picture_path])->andFilterWhere(['like', 'publish_status', $this->publish_status]);
     return $dataProvider;
 }