/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request)
 {
     $groups = group::lists('name', 'group_id');
     $locations = location::orderBy('location_id')->lists('location', 'location_id');
     //$locations = array_merge($locations, array('0', 'National'));
     $group_id = $request->input('group_id');
     $location_id = $request->input('location_id');
     if (!isset($group_id)) {
         $group_id = 1;
     }
     if (!isset($location_id)) {
         $location_id = 0;
     }
     /*				
     $rankings = \DB::table('rankings')
     		->join('players', 'rankings.player_id', '=', 'players.player_id')
     		->join('groups', 'rankings.group_id', '=', 'groups.group_id')
     		->join('locations', 'rankings.location_id', '=', 'locations.location_id')
     		->where('ranking_date', '=', $latest_date)
     		->where('rankings.group_id', '=', $group_id)
     		->where('rankings.location_id', '=', $location_id)
     		->distinct()
     		->get();
     */
     $ranking = new Ranking();
     $rankings = $ranking->getlatestRankings($group_id, $location_id);
     return view('pages/rankings', compact('rankings', 'groups', 'locations'));
 }
 /**
  * Insert new Ranking
  *
  * @param  array  $data
  * @return Ranking
  */
 public function create_ranking(array $data)
 {
     $ranking = \DB::table('rankings')->where('ranking_date', '=', $data['ranking_date'])->where('group_id', '=', $data['group_id'])->where('location_id', '=', $data['location_id'])->where('player_id', '=', $data['player_id'])->first();
     if (is_null($ranking)) {
         return Ranking::create(['ranking_date' => $data['ranking_date'], 'player_id' => $data['player_id'], 'ranking' => $data['ranking'], 'group_id' => $data['group_id'], 'location_id' => $data['location_id']]);
     }
 }
Example #3
0
 public function rank($slot)
 {
     if (\App\Ranking::where('slot_code', '=', $slot->slot_code)->exists() == false) {
         $rank = new \App\Ranking();
         $rank->slot_code = $slot->slot_code;
         $rank->user_id = $slot->user_id;
         $rank->save();
         $rank->slot_rank = $rank->id;
         $rank->slot_exit = 0;
         $rank->save();
         $tv1 = $rank->id;
         $tv2 = $rank->id * 2;
         $tv3 = $tv2 * 2;
         $tree = new \App\Tree();
         $tree->down1 = $tv2;
         $tree->down2 = $tv2 + 1;
         $tree->down3 = $tv3;
         $tree->down4 = $tv3 + 1;
         $tree->down5 = $tv3 + 2;
         $tree->down6 = $tv3 + 3;
         $tree->save();
         $rank->tree_id = $tree->id;
         $rank->save();
     }
 }
 public function guardaProgresso(Request $request)
 {
     $disciplina = $_SESSION['disciplina'];
     $nome = $request->input('nome');
     $nota = $request->input('nota');
     $nrRespostasCertas = $request->input('nrRespostasCertas');
     $nrRespostasErradas = $request->input('nrRespostasErradas');
     //Caso aconteça um erro nesse código
     $valido = true;
     $erroMensagem = "";
     //formatação de data
     $dateTime = getdate();
     $dia = $dateTime['mday'];
     $mes = $dateTime['mon'];
     $ano = $dateTime['year'];
     $dia = $dia > 9 ? $dia : "0" . $dia;
     $mes = $mes > 9 ? $mes : "0" . $mes;
     $dataRealizacao = $ano . "-" . $mes . "-" . $dia;
     $user = User::firstOrCreate(['name' => $nome]);
     $exercicio = new Exercicio();
     $exercicio->nota = $nota;
     $exercicio->respostas_certas = $nrRespostasCertas;
     $exercicio->respostas_erradas = $nrRespostasErradas;
     $exercicio->data_realizacao = $dataRealizacao;
     $exercicio->user_id = $user->id;
     $exercicio->disciplina_id = $disciplina->id;
     $exercicio->save();
     $ranking = Ranking::all()->where('user_id', $user->id)->where('disciplina_id', $disciplina->id)->first();
     if ($ranking) {
         $ranking->nota = $nota;
         $ranking->save();
     } else {
         $ranking = new Ranking();
         $ranking->nome_user = $nome;
         $ranking->nome_disciplina = $disciplina->nome;
         $ranking->nota = $nota;
         $ranking->dia_realizacao = $dataRealizacao;
         $ranking->user_id = $user->id;
         $ranking->disciplina_id = $disciplina->id;
         $ranking->save();
     }
     $dadosResposta = [$nome, $valido, $erroMensagem];
     $dadosResposta = json_encode($dadosResposta);
     return $dadosResposta;
 }
 /**
  * Store a newly created Cruiseline.
  *
  * @param Request $request
  * @param Cruiseline $brand
  * @return mixed
  */
 public function store(CreateRank $request)
 {
     $rankings = Ranking::where('rankable_type', '=', 'App\\Brochure')->delete();
     $rankable_type = $request->rankable_type;
     $count = count($request->rankable_id);
     for ($i = 0; $i < $count; $i++) {
         $ranking = Ranking::create(['rank' => $i + 1, 'rankable_type' => $rankable_type, 'rankable_id' => $request->rankable_id[$i]]);
     }
     return redirect('home/brochurerankings');
 }
 public function checkExits()
 {
     $ranks = \App\Ranking::all();
     foreach ($ranks as $rank) {
         if ($ranks->count() >= $rank->id * 2 * 2 + 3) {
             $rank->slot_exit = 1;
             $rank->save();
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $ranks = \App\Ranking::all();
     foreach ($ranks as $rank) {
         if ($ranks->count() >= $rank->id * 2 * 2 + 3) {
             $rank->slot_exit = 1;
             $rank->save();
         }
     }
     $this->info('Ranks Updated');
 }
Example #8
0
    if (get_headers('http://www.r2sports.com/tourney/imageGallery/gallery/player/' . $player_id . '_normal.jpg')[0] != 'HTTP/1.1 404 Not Found') {
        $profile = 'http://www.r2sports.com/tourney/imageGallery/gallery/player/' . $player_id . '_normal.jpg';
    } else {
        $profile = '/images/racquet-right.png';
    }
    return $profile;
});
Route::get('api/rankings/history', function () {
    $player_id = (int) Input::get('player_id');
    $group_id = Input::get('group_id');
    $location_id = (int) Input::get('location_id');
    $location = Location::find($location_id);
    $player = Player::find($player_id);
    $rankings = Ranking::where('player_id', '=', $player_id)->select('ranking_date', 'location_id', 'ranking')->orderBy('ranking_date')->get();
    /*National Ranking*/
    $national = Ranking::where('player_id', '=', $player_id)->where('location_id', '=', 0)->select('ranking_date', 'ranking')->orderBy('ranking_date')->get();
    $query = "\n\t\tSELECT \n\t\t\tdate_format(ranking_date, '%m/%d/%Y') as ranking_date,\n\t\t\tranking\n\t\tFROM\n\t\t\trankings\n\t\tWHERE\n\t\t\tplayer_id = {$player_id}\n\t\t\tAND location_id = 0\n\t\t\tAND group_id = {$group_id}\n\t\tORDER BY \n\t\t\tranking_date\n\t\t";
    $national = \DB::select(DB::raw($query));
    $arr_national = array();
    foreach ($national as $key => $n) {
        $row = array();
        $row['ranking_date'] = $n->ranking_date;
        $row['National'] = intval($n->ranking);
        array_push($arr_national, $row);
    }
    //dd($player);
    /*State Ranking*/
    $query = "\n\t\tSELECT \n\t\t\tdate_format(ranking_date, '%m/%d/%Y') as ranking_date,\n\t\t\tranking\n\t\tFROM\n\t\t\trankings\n\t\tWHERE\n\t\t\tplayer_id = {$player_id}\n\t\t\tAND group_id = {$group_id}\n\t\t\tAND location_id = {$location_id}\n\t\tORDER BY \n\t\t\tranking_date\n\t\t";
    $state = \DB::select(DB::raw($query));
    $arr_state = array();
    foreach ($state as $key => $n) {
 public function ranking()
 {
     $ranks = \App\Ranking::all();
     return view('dashboard.admin.rank')->with(['user' => \Auth::User(), 'ranks' => $ranks]);
 }
 public function ranking($disciplina_id)
 {
     $rankings = Ranking::all()->where('disciplina_id', $disciplina_id)->sortByDesc('nota');
     //->groupBy('nota')->sortByDesc('nota');
     return $rankings;
 }