/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Photos::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, 'album_id' => $this->album_id]); $query->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'caption', $this->caption])->andFilterWhere(['like', 'alt_text', $this->alt_text]); return $dataProvider; }
/** * Displays a single Album model. * @param integer $id * @return mixed */ public function actionView($id) { $dataProvider = new ActiveDataProvider(['query' => Photos::find()->where(['album_id' => '' . $id])]); return $this->render('view', ['model' => $this->findModel($id), 'dataProvider' => $dataProvider]); }