/** * Lists all DictEn models. * @return mixed */ public function actionIndex() { // $searchModel = new DictEnQuery(); // $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $hot = DictEn::find()->hot()->all(); $album = DictEnAlbum::find()->all(); return $this->render('index', ['album' => $album, 'hot' => $hot]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DictEnAlbum::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, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'comment_time' => $this->comment_time, 'author_id' => $this->author_id, 'comment_num' => $this->comment_num, 'view_num' => $this->view_num, 'fav_num' => $this->fav_num, 'digg_num' => $this->digg_num, 'share_num' => $this->share_num]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'litPic', $this->litPic])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }