/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Vocabulary::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(['like', 'wordId', $this->wordId])->andFilterWhere(['like', 'german', $this->german])->andFilterWhere(['like', 'russian', $this->russian])->andFilterWhere(['like', 'context', $this->context]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Vocabulary::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(['like', 'date', $this->date])->andFilterWhere(['like', 'word', $this->word])->andFilterWhere(['like', 'meaning', $this->meaning])->andFilterWhere(['like', 'updater', $this->updater]); return $dataProvider; }
public function actionTranslation() { $query = Vocabulary::find(); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $words = $query->orderBy('german')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('translation', ['words' => $words, 'pagination' => $pagination]); }