Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $this->generateSessionValueIfNotExists();
     $data['teams'] = [];
     $teams = Team::orderBy('name', 'asc')->get();
     foreach ($teams as $team) {
         $isFavourite = Rating::where('session', '=', $_SESSION["session"])->where('team_id', '=', $team->id)->get();
         if (count($isFavourite) > 0) {
             $team->isFavourite = true;
         } else {
             $team->isFavourite = false;
         }
         array_push($data['teams'], $team);
     }
     //$data['ratings'] = Rating::all();
     $data['ratings'] = DB::select('select count(*) as votos, t.name as equipo, t.link as enlace, u.name as usuario
                         from ratings as r
                         join teams as t on r.team_id = t.id
                         join users as u on t.user_id = u.id
                         group by r.team_id
                         order by votos desc, t.name asc');
     //dd($data);
     $data['last_teams'] = Team::orderBy('id', 'desc')->limit(5)->get();
     $data['users'] = User::all();
     return view('welcome.welcome', $data);
 }
Ejemplo n.º 2
0
 public function actionDelete($id)
 {
     $user = Auth::user();
     $rating = Rating::where('user_id', '=', $user->id)->findOrFail($id);
     $rating->delete($rating);
     \Session::flash('flash_message', 'You have successfully deleted a rating.');
     return redirect('ratings');
 }
 public function checkMinVotes($iterinary_id)
 {
     $numOfVotes = Rating::where("ratingable_type", "Iterinary")->where("ratingable_id", $iterinary_id)->get();
     if (count($numOfVotes) >= 5) {
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public function retrieve()
 {
     $pc = Request::get('postcode');
     $icity = Postcode::where("Postcode", "=", "{$pc}")->first();
     $itemsair = Rating::where("Postcode", "=", "{$pc}")->where("Type", "=", "Air")->get();
     $itemsnoise = Rating::where("Postcode", "=", "{$pc}")->where("Type", "=", "Noise")->get();
     $itemsland = Rating::where("Postcode", "=", "{$pc}")->where("Type", "=", "Land")->get();
     return view('display', compact('itemsair', 'itemsnoise', 'itemsland', 'icity'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['The Great Gatsby' => ['1'], 'A Fire in the Deep' => ['5'], 'Deepness in the Sky' => ['10']];
     foreach ($books as $title => $rating) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($rating as $ratingName) {
             $rating = \App\Rating::where('rating', 'LIKE', $ratingName)->first();
             $book->ratings()->save($rating);
         }
     }
 }
 public function show(Request $request)
 {
     $result = Rating::where(['user_id_from' => $request->input('user_id_from'), 'user_id_to' => $request->input('user_id_to')])->first();
     if (!$result) {
         $result = array();
         foreach (Rating::$RATING_TYPES as $type) {
             $result[Rating::RATING_COLUMN_PREFIX . $type] = 0;
         }
     }
     return response()->json($result);
 }
Ejemplo n.º 7
0
 public function ratingForUser($userId)
 {
     $rating = Rating::where('givenTo', '=', $userId)->get();
     $ratingValues = array_column($rating->toArray(), 'ratingValue');
     $sum = 0;
     foreach ($ratingValues as $ratingValue) {
         $sum += $ratingValue;
     }
     $finalRating = count($ratingValues) > 0 ? $sum / count($ratingValues) : 0;
     return $finalRating;
 }
Ejemplo n.º 8
0
 public function viewUpdate($id)
 {
     $user = Auth::user();
     $movie = Movie::where('user_id', '=', $user->id)->findOrFail($id);
     $genres = Genre::where('user_id', '=', $user->id)->orderBy('name', 'asc')->get();
     $ratings = Rating::where('user_id', '=', $user->id)->orderBy('name', 'asc')->get();
     $directors = Director::where('user_id', '=', $user->id)->orderBy('name', 'asc')->get();
     $writers = Writer::where('user_id', '=', $user->id)->orderBy('name', 'asc')->get();
     $casts = Cast::where('user_id', '=', $user->id)->orderBy('name', 'asc')->get();
     $labels = Label::where('user_id', '=', $user->id)->orderBy('name', 'asc')->get();
     return view('movies.viewUpdate')->with('movie', $movie)->with('genres', $genres)->with('ratings', $ratings)->with('directors', $directors)->with('writers', $writers)->with('casts', $casts)->with('labels', $labels);
 }
Ejemplo n.º 9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($team_id)
 {
     $team = Team::find($team_id);
     if (!$team) {
         abort(404);
     }
     $message = "" . $team->name . " ha dejado de ser un equipo favorito. ¿Por qué?";
     session_start();
     $registro = Rating::where('team_id', '=', $team_id)->where('session', '=', $_SESSION["session"])->get();
     $registro[0]->delete();
     return redirect()->route('welcome')->with('status', 'danger')->with('message', $message);
 }
 /**
  * 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']);
     }
 }
 /**
  * @param Request $request
  * @return array
  */
 public function store(Request $request)
 {
     if (Auth::check()) {
         $request['user_id'] = Auth::id();
         if (!Rating::where('book_id', '=', $request->book_id)->where('user_id', '=', $request->user_id)->exists()) {
             Rating::create($request->all());
             return 1;
             // Added
         }
         return 2;
         // You have already voted on this Books
     } else {
         return 3;
         // You are not Logged
     }
     return $input;
 }
 public function rate($id)
 {
     $wbbUId = \Input::get('wbbUId');
     $i = explode('_', explode(' ', \Input::get('clickedOn'))[0])[1];
     $c = Rating::where('downloadId', $id)->where('WbbUId', $wbbUId)->count();
     if ($c > 0) {
         Rating::where('downloadId', $id)->where('WbbUId', $wbbUId)->update(array('value' => $i));
     } else {
         Rating::create(array('value' => $i, 'downloadId' => $id, 'WbbUId' => $wbbUId));
     }
     return response(array('avg' => intval(round(Rating::getAvg($id)))));
 }
 /**
  * Get Book Rating
  * @param $id
  * @return mixed
  */
 public function getBookRating($id)
 {
     $bookRating = round(Rating::where('book_id', '=', $id)->avg('rating'));
     return $bookRating;
 }
Ejemplo n.º 14
0
 public function getProfileByUserID($userid)
 {
     $user_id = $userid;
     $userSkills = User::find($user_id)->skill;
     $user = User::find($user_id);
     $ratings = \App\Rating::where('freelancer_id', '=', $user_id)->get();
     $rating_value = \App\Rating::where('freelancer_id', '=', $user_id)->avg('rating');
     // skills
     $skill_categories = \App\SkillCategories::all();
     $user_id = \Auth::user()->id;
     $skillsByCategory = array();
     $i = 0;
     foreach ($skill_categories as $category) {
         $skillsByCategory[$i++] = Skill::where('skill_category_id', '=', $category->id)->get();
     }
     //-------------
     return View::make('profile')->with('userSkills', $userSkills)->with('user', $user)->with('ratings', $ratings)->with('skill_categories', $skill_categories)->with('userSkills', $userSkills)->with('skillsByCategory', $skillsByCategory)->with('rating_value', $rating_value);
 }
Ejemplo n.º 15
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');
 }
Ejemplo n.º 16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  film id  $id
  * @param  fl_rating $old
  * @return Response
  */
 public function betterRating($id, $old)
 {
     $numVote = Rating::where('rt_fl_id', $id)->count();
     $sumVote = Rating::where('rt_fl_id', $id)->sum('rt_vote');
     $old = round($old, 1);
     if ($numVote == 0) {
         if ($old == 0) {
             return '-';
         } else {
             return $old;
         }
     } else {
         if ($numVote > 0 && $numVote < 5) {
             if ($old == 0) {
                 return '-';
             } else {
                 return $old;
             }
         } else {
             if ($numVote > 4) {
                 return round($sumVote / $numVote, 1);
             }
         }
     }
 }
 public function getEachAvgRating()
 {
     return Rating::where("ratingable_type", "Iterinary")->selectRaw("ratingable_id, avg(value)")->groupBy("ratingable_id")->orderBy("avg(value)", "DESC")->get();
 }