/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Review::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['datetime' => SORT_DESC]]]); $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, 'user_id' => $this->user_id, 'datetime' => $this->datetime]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Review::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, 'category_id' => $this->category_id, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_description', $this->meta_description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Review::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'good_id' => $this->good_id, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public function run() { parent::run(); // TODO: Change the autogenerated stub $categoriesData = ReviewCategory::findOne($this->category_id)->leaves()->all(); $categories = array(); $categories[] = $this->category_id; if ($categoriesData) { foreach ($categoriesData as $category) { $categories[] = $category->id; } } $offset = Review::find()->where(['in', 'category_id', $categories])->andWhere(['>', 'id', $this->node_id])->andFilterWhere(['status' => 10])->orderBy(['id' => SORT_DESC])->count(); $nodes = Review::find()->where(['in', 'category_id', $categories])->andFilterWhere(['status' => 10])->orderBy(['id' => SORT_DESC])->limit(4)->offset($offset)->all(); return $this->render('RelatedReviewWidget', ['nodes' => $nodes]); }
public function actionView($slug) { $model = $this->findModel($slug); $categoriesData = $model->leaves()->all(); $categories = array(); $categories[] = $model->id; if ($categoriesData) { foreach ($categoriesData as $category) { $categories[] = $category->id; } } $category_title = $model->title; $nodesModel = Review::find()->where(['in', 'category_id', $categories]); $count = $nodesModel->count(); $pagination = new Pagination(['totalCount' => $count]); $nodes = $nodesModel->offset($pagination->offset)->limit(10)->orderBy(['id' => SORT_DESC])->all(); return $this->render('view', ['title' => $category_title, 'root' => $model->tree, 'nodes' => $nodes, 'pagination' => $pagination]); }
public function actionReviews() { $model = new Review(); $query = Review::find()->where(['status' => 1])->orderBy(['datetime' => SORT_DESC]); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count()]); $pages->pageSize = 10; $models = $query->offset($pages->offset)->limit($pages->limit)->all(); return $this->render('reviews', ['reviews' => $models, 'pages' => $pages, 'model' => $model]); }
public static function getData() { $reviewModel = new Review(); $reviewData = $reviewModel->find()->limit(12)->all(); return $reviewData; }