public function getHandicap(Request $request) { # Get all the rounds "owned" by the current logged in users # Sort in ascending order by id $rounds = \App\Round::where('user_id', '=', \Auth::id())->orderBy('id', 'ASC')->get(); return view('handicap')->with('rounds', $rounds); }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // $schedule->command('inspire') // ->hourly(); /** * Ranking system to calculate Ranks in the * test 7 minutes after the test is completed. * This cron job will be called hourly. */ $schedule->call(function () { $rounds = Round::where('end_date_time', '<', Carbon::now()->subMinutes(7))->where('ranked', false)->get(); foreach ($rounds as $round) { $qualifiers = Qualifier::where('round_id', $round->id)->orderBy('score', 'desc')->orderBy('completion_time', 'asc')->get(); $i = 1; foreach ($qualifiers as $qualifier) { $qualifier->rank = $i; $qualifier->save(); $i++; } if ($round->cutoff) { $next_qualifiers = Qualifier::where('round_id', $round->id)->where('rank', '<=', $round->cutoff)->get(); $next_round = $round->event->rounds->where('no', strval($round->no + 1))->first(); foreach ($next_qualifiers as $next_qualifier) { $qualifier = new Qualifier(); $qualifier->save(); $next_round->qualifiers()->save($qualifier); $next_qualifier->student->qualifiers()->save($qualifier); } } $round->ranked = true; $round->save(); } })->everyMinute(); }
/** * Display a listing of the resource. * * @return Response */ public static function index($id, array $data = ['y' => 0]) { $challenge = Challenge::find($id); $challenge_name = $challenge->name; $group = Group::where('challenge_id', '=', $id)->get()->toArray(); $teamRound = Round::where('challenge_id', '=', $id)->orderBy('team_id', 'DESC')->get()->toArray(); $countTeamRound = count($teamRound); $countGroup = count($group) + $data['y']; $div = $countTeamRound / $countGroup; $p = 0; for ($i = $data['y']; $i <= count($teamRound) - 1; $i++) { if (!Groupsta::where('round_id', '=', $teamRound[$i]['id'])->first()) { Groupsta::create(['round_id' => $teamRound[$i]['id'], 'group_id' => $group[$p]['id'], 'challenge_id' => $id]); } if ($i == $countGroup - 1) { GroupstaController::index($id, $data = ['y' => $i + 1]); break; } $p++; } if (!ENV('DEVELOP')) { $data = GroupstaController::pagination($id); $dataG = []; $dataG += ['' => '-- Seleciona Grupo --']; $datagro = Group::where('challenge_id', '=', $id)->lists('name', 'id')->toArray(); $dataG += $datagro; return view('groupsstage.index', compact('data', 'challenge_name', 'dataG')); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $liendivision = $this->argument('liendivision'); $id = $this->argument('id'); $matchs = xml_result_equ('', $liendivision); foreach ($matchs as $match) { $round = Round::where('team_id', $id)->where('equa', $match->equa)->where('equb', $match->equb)->first(); if ($round == null) { $round = new Round(); } $round->team_id = $id; $round->libelle = $match->libelle; $round->equa = $match->equa; $round->equb = $match->equb; $round->scorea = $match->scorea; $round->scoreb = $match->scoreb; $round->lien = $match->lien; $round->save(); Artisan::queue('FFTT:Games', ['lien' => $match->lien, 'id' => $round->id]); } }
public function checkRoundBelongsToUser($userId, $roundId) { return Round::where('user_id', $userId)->where('id', $roundId)->exists(); }
public function modification(Request $request) { if ($request->type == 1) { $dataRoundGet = Round::find($request->round_id); $dataRoundGet->active = 0; $dataRoundGet->save(); $dataRound = Round::where('challenge_id', '=', $request->challenge_id)->where('stage_id', '=', $dataRoundGet->stage_id)->orderBy('id', 'DESC')->first(); $date = new DateTime($dataRound->schedule_end); $hora_end = date('H:i:s', strtotime($date->format('H:i:s') . '+' . Settings::durationTrial() . ' minute')); $date_end = new DateTime($hora_end); $time_dos = Settings::durationTrial(); $hora_start = strtotime('-' . $time_dos . ' minute', strtotime($date_end->format('H:i:s'))); $hora_start = date('H:i:s', $hora_start); $dia = date('Y-m-d ', strtotime($date->format('H:i:s') . '+' . env('TIME') . ' minute')); Round::create(['team_id' => $dataRoundGet->team_id, 'challenge_id' => $dataRoundGet->challenge_id, 'schedule_start' => $hora_start, 'schedule_end' => $hora_end, 'stage_id' => $dataRoundGet->stage_id]); } else { $Round = Round::find($request->round_id); if ($request->typeText == 'active') { $Round->active = 1; } else { $Round->active = 0; } $Round->save(); } return $this->index($request->challenge_id); }