/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Question::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, 'pid' => $this->pid, 'relid' => $this->relid, 'questioner' => $this->questioner, 'orderid' => $this->orderid, 'status' => $this->status, 'is_show' => $this->is_show, 'source' => $this->source, 'views' => $this->views, 'answers' => $this->answers, 'create_at' => $this->create_at, 'is_rec' => $this->is_rec]); $query->andFilterWhere(['like', 'question', $this->question])->andFilterWhere(['like', 'detail', $this->detail])->andFilterWhere(['like', 'label', $this->label]); return $dataProvider; }
/** * Get question by order. * @param $question */ public function getByOrder($question) { return Question::find()->where(['_id' => ['$in' => $question]])->orderBy(['order' => SORT_ASC])->all(); }