/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = researchnote::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(['created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'id' => $this->id]); $query->andFilterWhere(['like', 'topic_id', $this->topic_id])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'source', $this->source])->andFilterWhere(['like', 'source_id', $this->source_id])->andFilterWhere(['like', 'source_authors', $this->source_authors])->andFilterWhere(['like', 'source_date', $this->source_date])->andFilterWhere(['like', 'source_publisher', $this->source_publisher])->andFilterWhere(['like', 'source_url', $this->source_url])->andFilterWhere(['like', 'source_file', $this->source_file])->andFilterWhere(['like', 'source_text', $this->source_text])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'updated_by', $this->updated_by]); return $dataProvider; }
public function actionXml() { $models = researchnote::find()->all(); $data = array_map(function ($model) { return $model->attributes; }, $models); $response = Yii::$app->response; $response->format = Response::FORMAT_XML; $response->data = $data; return $response; }