/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DictEn::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, 'author_id' => $this->author_id]); $query->andFilterWhere(['like', 'title', $this->title . '%', false]); return $dataProvider; }
/** * Displays a single DictEn model. * @param string $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); $model->updateCounters(['view_num' => 1]); return $this->render('view', ['model' => $model, 'similar' => DictEn::find()->similar($model->title)->all()]); }