Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateRatingRequest $request, $id)
 {
     $restaurant = Restaurant::findOrFail($id);
     $rating = new Rating();
     $rating->fill($request->input());
     $rating->restaurant()->associate($restaurant);
     $rating->save();
     return $restaurant;
 }
Exemplo n.º 2
0
 public function storeRating()
 {
     if (Request::ajax()) {
         $input = Request::all();
         $rating = new Rating($input);
         $rating->ip = Request::getClientIp();
         $rating->save();
         return response(200);
     }
 }
Exemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, RentalUnit $rental, User $user)
 {
     $rating = $rental->ratings()->where('from_user', $user->id)->first();
     if ($rating == null) {
         $rating = new Rating();
     }
     $rating->fill(Input::all());
     $rating->save();
     //        $rating->avgRating = $rental->ratings()->avg('rating_points');
     return Response::json($rating);
 }
Exemplo n.º 4
0
 public function rate(Request $request, $courseSlug, $lessonSlug)
 {
     $this->validate($request, ['rating' => 'required|numeric|between:1,5', 'comment' => 'required']);
     $course = Course::where('slug', $courseSlug)->firstOrFail();
     $lesson = Lesson::where('slug', $lessonSlug)->where('course_id', $course->id)->firstOrFail();
     $rating = new Rating();
     $rating->lesson_id = $lesson->id;
     $rating->user_id = Auth::user()->id;
     $rating->rating = $request->rating;
     $rating->comment = $request->comment;
     $rating->save();
     return redirect(action('LessonController@show', [$courseSlug, $lessonSlug]));
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getCreate($dishId, $rating)
 {
     $data = ['dish' => $dishId, 'rating' => $rating];
     if (Rating::where('dish_id', '=', $dishId)->where('rater_id', '=', Auth::user()->id) || 0 <= $rating || $rating <= 5) {
         $ratingObject = new Rating();
         $ratingObject->rating = $rating;
         $ratingObject->dish_id = $dishId;
         $ratingObject->rater_id = Auth::user()->id;
         $ratingObject->save();
         return redirect()->back()->withSuccess('you have rated this dish');
     } else {
         return redirect()->back()->withErrors(['something went wrong with your vote']);
     }
 }
Exemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $team_id)
 {
     $team = Team::find($team_id);
     if (!$team) {
         abort(404);
     }
     $message = $team->name . " es uno de tus equipos favoritos! Enhorabuena";
     session_start();
     $rating = new Rating();
     $rating->team_id = $team_id;
     $rating->session = $_SESSION["session"];
     $rating->save();
     return redirect()->route('welcome')->with('status', 'success')->with('message', $message);
 }
Exemplo n.º 7
0
 public function ratingFreelancer()
 {
     if (\Request::ajax()) {
         $freelancer_id = Input::get('freelancer_id');
         $comment = Input::get('comment');
         $rating_num = Input::get('rating');
         $rating_temp = new \App\Rating();
         $rating_temp->freelancer_id = $freelancer_id;
         $rating_temp->comment = $comment;
         $rating_temp->rating = $rating_num;
         $rating_temp->save();
         echo json_encode(array('succ' => 1));
     }
     //View::make('index');
 }
Exemplo n.º 8
0
 function updateRating(Request $request)
 {
     if (Rating::where('user_id', $request->user_id)->where('item_id', $request->item_id)->exists()) {
         Rating::where('user_id', $request->user_id)->where('item_id', $request->item_id)->update(['rating' => $request->rating]);
     } else {
         $rating_relation = new Rating();
         $rating_relation->user_id = $request->user_id;
         $rating_relation->item_id = $request->item_id;
         $rating_relation->rating = $request->rating;
         $rating_relation->save();
     }
     return redirect('/relogin');
 }
 public function addrating(Request $request)
 {
     $token = $request->token;
     if ($token == null) {
         return response()->json('token is empty', 200);
     }
     $user = userSessionHandler::user($token);
     if ($user == null) {
         return response()->json('user not found.', 404);
     }
     $rating = new Rating();
     $rating->user_id = $user->id;
     $rating->value = $request->value;
     $rating->ratingable_id = $request->ratingable_id;
     $rating->ratingable_type = $request->ratingable_type;
     $rating->save();
     if ($request->ratingable_type == "Iterinary") {
         \Event::fire(new IterinaryRateWasAdded($request->ratingable_id));
     } else {
         \Event::fire(new ActivityRateWasAdded($request->ratingable_id));
     }
 }
Exemplo n.º 10
0
 public function setRate(Request $request)
 {
     $session_id = Session::getId();
     if (!$session_id) {
         return response('', 400);
     }
     $this->validate($request, ['lesson_id' => 'required|integer', 'rating' => 'required|integer']);
     $rate = new Rating();
     $rate->lesson_id = $request->lesson_id;
     $rate->rating = $request->rating;
     $rate->session_id = $session_id;
     $rate->save();
     return response('', 201);
 }