コード例 #1
0
ファイル: ReviewSearch.php プロジェクト: RStuffGit/mebel
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: ReviewSearch.php プロジェクト: kotmonstr/kotmonstr
 /**
  * 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;
 }
コード例 #4
0
 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]);
 }
コード例 #5
0
 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]);
 }
コード例 #6
0
ファイル: SiteController.php プロジェクト: RStuffGit/mebel
 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]);
 }
コード例 #7
0
 public static function getData()
 {
     $reviewModel = new Review();
     $reviewData = $reviewModel->find()->limit(12)->all();
     return $reviewData;
 }