/** * 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; }
/** * Finds the Vocabulary model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Vocabulary the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Vocabulary::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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]); }