public function search($params) { $query = Review::find()->orderBy('date DESC, id DESC'); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'item_id' => $this->item_id, 'active' => $this->active, 'vote' => $this->vote]); $query->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'pluses', $this->pluses])->andFilterWhere(['like', 'minuses', $this->minuses])->andFilterWhere(['like', 'date', $this->date]); return $dataProvider; }
protected function findModel($id) { if (($model = Review::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested review does not exist.'); } }
public function run() { $list = Review::find()->limit($this->limit)->where(['item_id' => $this->itemId, 'active' => 'yes'])->all(); return $this->render('reviews', ['list' => $list]); }