public function submitReview($id)
 {
     $input = array('comment' => Input::get('comment'), 'rating' => Input::get('rating'));
     // instantiate Rating model
     $review = new Review();
     // Validate that the user's input corresponds to the rules specified in the review model
     $validator = Validator::make($input, $review->getCreateRules());
     // If input passes validation - store the review in DB, otherwise return to product page with error message
     if ($validator->passes()) {
         $review->storeReviewForProduct($id, $input['comment'], $input['rating']);
         return \Redirect::to('products/' . $id . '#reviews-anchor')->with('review_posted', true);
     }
     return \Redirect::to('products/' . $id . '#reviews-anchor')->withErrors($validator)->withInput();
 }
예제 #2
0
 public function postReview($id)
 {
     $input = array('comment' => \Input::get('comment'), 'rating' => \Input::get('rating'));
     $review = new Review();
     $validator = \Validator::make($input, $review->getCreateRules());
     if ($validator->passes()) {
         $review->storeReviewForBiz($id, $input['comment'], $input['rating']);
         return redirect('review/biz/' . $id . '#company-reviews')->with('success', 'Review Submitted successfully');
     }
     return redirect('review/biz/' . $id . '#company-reviews')->with('errors', $validator->messages())->withInput();
 }