/**
  * Finds the ReviewCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $slug
  * @return ReviewCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($slug)
 {
     if (($model = Review::findOne(['slug' => $slug])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #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, '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;
 }
Exemple #4
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 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 actionDetail()
 {
     $data = $this->getCommonDate();
     $modelBest = Goods::getBest(3);
     $iP = Yii::$app->session->id;
     $quantityInCart = Cart::getQountAllByIp($iP);
     $id = Yii::$app->request->get('item');
     $modelReview = Review::getReviewsByGoodId($id);
     $modelGoodsCategories = GoodsCategory::find()->all();
     $modelBrends = Brend::find()->all();
     if (!$id) {
         $this->redirect('/shop/index');
     }
     $model = Goods::getItemById($id);
     $modelPhotos = GoodsPhotos::getItemsByGoodId($id);
     $_modelReview = new Review();
     return $this->render('detail', ['modelPhotos' => $modelPhotos, 'data' => $data, 'model' => $model, 'modelGoodsCategories' => $modelGoodsCategories, 'modelReview' => $modelReview, '_modelReview' => $_modelReview, 'modelBest' => $modelBest, 'modelBrends' => $modelBrends]);
 }
Exemple #8
0
 public function actionAddReview()
 {
     $model = new Review();
     $model->load(Yii::$app->request->post());
     $model->user_id = Yii::$app->user->getId();
     $result = $model->save();
     if (!$result) {
         //            var_dump($model->getErrors()); die;
     }
     return $this->redirect(['reviews']);
 }
 public static function getData()
 {
     $reviewModel = new Review();
     $reviewData = $reviewModel->find()->limit(12)->all();
     return $reviewData;
 }
Exemple #10
0
 public function getReview()
 {
     return $this->hasOne(Review::className(), ['id' => 'objectId']);
 }
Exemple #11
0
 public function actionConfirmed()
 {
     $codeBankCampaign = new CodeBankCampaign();
     $codeBankCampaign->loadDefaultValues();
     $review = new Review();
     $review->loadDefaultValues();
     $request = Yii::$app->request;
     if ($request->isPost && $codeBankCampaign->load($request->post()) && $review->load($request->post())) {
         $isValid = $codeBankCampaign->validate();
         $isValid = $review->validate() && $isValid;
         if ($isValid) {
             if ($review->save()) {
                 $codeBankCampaign->objectId = $review->id;
                 $codeBankCampaign->save();
                 return $this->redirect(['/campaign/index']);
             }
         }
     }
     return $this->render('step', ['model' => $review, 'codeBankCampaign' => $codeBankCampaign]);
 }