コード例 #1
0
 /**
  * @param $product_id
  * @param UpdateReviewBindingModel $input
  * @param Reviews $reviews
  * @return $this->redirect
  */
 public function update($product_id, UpdateReviewBindingModel $input, Reviews $reviews)
 {
     if ($reviews->hasCurrentUserReviewed($product_id)) {
         $reviews->update($product_id, $this->auth->user()->id, $input->getStars(), $input->getReview());
     } else {
         $reviews->add($product_id, $this->auth->user()->id, $input->getStars(), $input->getReview());
     }
     return $this->redirect->to('/products/product/' . $product_id)->withSuccess(['Review is updated successfully'])->go();
 }
コード例 #2
0
 /**
  * Finds the Reviews model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Reviews the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Reviews::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Reviews::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]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * @param $id
  * @param Products $products
  * @param Reviews $reviews
  * @param Categories $categories
  * @param Promotions $promotions
  * @throws \Exception
  */
 public function getProduct($id, Products $products, Reviews $reviews, Categories $categories, Promotions $promotions)
 {
     $cart = $this->session->getSession()->cart ?: [''];
     $this->view->appendToLayout('body', "products.product");
     $this->view->display('layouts.main', ['product' => $products->get($id), 'cart' => $cart, 'promotion' => $promotions->getProductPromotion($id) ?: null, 'reviews' => $reviews->getForProduct($id), 'current_user_review' => $reviews->getForUser($this->auth->user()->id, $id), 'categories' => $categories->listAllNames()]);
 }
コード例 #5
0
 /**
  * Review page
  * @return \Illuminate\View\View
  */
 public function showReviews()
 {
     $reviews = $this->review->all();
     $this->title = 'Yogaground Reviews and Testimonials';
     return $this->getView('reviews', ['reviews' => $reviews]);
 }
コード例 #6
0
 public function actionRev()
 {
     $reviews = Reviews::find()->orderBy('rand()')->all();
     return $this->render('rev', ['reviews' => $reviews]);
 }