Esempio n. 1
0
 /**
  * Insert new Tournament
  *
  * @param  array  $data
  * @return Tournament
  */
 public function create_tournament(array $data)
 {
     $tourney = \DB::table('tournaments')->where('tournament_id', '=', $data['tournament_id'])->first();
     if (is_null($tourney)) {
         return Tournament::create(['tournament_id' => $data['tournament_id'], 'name' => $data['name'], 'img_logo' => $data['img_logo'], 'location' => $data['location'], 'start_date' => $data['start_date'], 'end_date' => $data['end_date']]);
     }
 }
Esempio n. 2
0
 public function start($id)
 {
     $tournament = Tournament::find($id);
     $participants = $tournament->participants;
     if ($tournament->started == false) {
         // $registrations =$tournament->registrations()->get();
         //  echo $registrations[0]->user()->get();
         // Von der Registrierung zum User
         $registrations = $tournament->registrations()->get();
         for ($i = 0; $i <= $participants / 2; $i = $i + 2) {
             echo "test" . $i;
             $player1 = $registrations[$i]->user()->get();
             $player2 = $registrations[$i + 1]->user()->get();
             $post = new Result();
             $post->user1()->associate($player1[0]);
             $post->user2()->associate($player2[0]);
             $post->tournament()->associate($tournament);
             $post->round = 0;
             $post->save();
         }
         $tournament->started = 1;
         $tournament->round = 0;
         //     $tournament->round++;
         $tournament->save();
     } else {
         $tournament_already_started_message = "Tournament already started";
     }
     //  echo count($registrations);
     return view('results.index', array("tournament_already_started_message" => $tournament_already_started_message, "started" => $tournament->started, 'tournament' => $tournament));
 }
 /**
  * Fills tournaments table
  *
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $t = Tournament::create(['name' => $faker->name(), 'min_number_of_teams' => $faker->numberBetween(2, 4), 'max_number_of_teams' => $faker->numberBetween(4, 16), 'start_date' => $faker->date('YYYY-MM-DD'), 'end_date' => $faker->date('YYYY-MM-DD'), 'type' => $faker->realText(100)]);
         $t->league()->associate(League::first())->save();
         //associate tournamnet with first league
     }
 }
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function scraper()
 {
     $success = '';
     $groups = Group::lists('name', 'group_id');
     $locations = Location::lists('location', 'location_id');
     //$tournaments = Tournament::orderBy('start_date', 'desc')
     //	->lists('name','tournament_id');
     $tournaments = Tournament::selectRaw('CONCAT(name, " (", start_date, ")") as name, tournament_id')->orderBy('start_date', 'desc')->lists('name', 'tournament_id');
     $players = Player::select('first_name', 'last_name', 'player_id', \DB::raw('CONCAT(first_name, " ", last_name) as full_name'))->orderBy('first_name')->orderBy('last_name')->get()->lists('full_name', 'player_id');
     return view('admin.scraper', compact('groups', 'locations', 'tournaments', 'players', 'success'));
 }
 public function add($id)
 {
     // Es würede auch Funktionieren wenn ich ein Turnier erstelle und diesem Benutzer hinzufüge.. (bessere Lösung)..
     $userid = Auth::user()->id;
     $registration = new Registration();
     $registration->tournament()->associate(Tournament::find($id));
     $registration->user()->associate(User::find($userid));
     $registration->save();
     return $this->index($id);
     // methoden parameter request apramter
 }
 public function fetchStartingTournaments()
 {
     $dateTimeNow = date('Y-m-d H:i:s', strtotime('+5 seconds'));
     $dateTimeSoon = date('Y-m-d H:i:s', strtotime('+600 seconds'));
     //echo $dateTimeNow . "<br>";
     $tournaments = \App\Tournament::where('loaded_to_server', 0)->where('starts_at', '>', $dateTimeNow)->where('starts_at', '<', $dateTimeSoon)->with('collection.problems')->get();
     // Set back info for each that we have loaded them
     // This should probably be done in a background job
     $tournaments->each(function ($tournament) {
         $tournament->loaded_to_server = 1;
         $tournament->save();
     });
     return response()->json($tournaments);
 }
 public function loadClientApp(\Illuminate\Http\Request $request)
 {
     // Get tournament key
     $key = $request->route('key');
     // Make sure tournament key matches to some tournament
     try {
         $tournament = \App\Tournament::where('key', $key)->firstOrFail();
     } catch (ModelNotFoundException $e) {
         \Session::flash('errorMsg', 'Tournament not found!');
         return \View::make('tournamentnotfound');
     }
     // Validate user inputted data
     // Framework will catch any throws higher up in call tree
     $this->validate($request, ['username' => 'required|min:2|max:32|alpha_num']);
     // All is fine
     // Launch client app
     return \View::make('clientApp')->with('username', \Input::get('username'))->with('tournamentkey', $tournament->key);
 }
 /**
  * Remove the specified tournament from storage.
  *
  * @param  int  $id Id of tournament to delete
  * @return Response route where to redirect after delete
  */
 public function destroy($id)
 {
     $tournament = Tournament::findOrFail($id);
     $tournament->delete();
     return redirect('/tournaments');
 }
 /**
  * [future description]
  * @return [type] [description]
  */
 public function future()
 {
     return Tournament::where('start_date', '>', date('Y-m-d'))->orderBy('start_date');
 }
Esempio n. 10
0
 /**
  * Display the specified team.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $team = Team::findOrFail($id);
     $users = User::all();
     $tournaments = Tournament::all();
     return view('/teams/team-details', ['team' => $team, 'users' => $users, 'tournaments' => $tournaments]);
 }
 private function createNewSecret($times = 0)
 {
     if ($times > 5) {
         return \App::abort(403, 'Could not create tournament secret key - contact administrator');
     }
     $chars = "qwertyuipasdfghjklzxcvbnm12345678900";
     $secret = "";
     for ($i = 0; $i < 4; $i++) {
         $r = rand(0, strlen($chars) - 1);
         $secret .= $chars[$r];
     }
     if (\App\Tournament::where('key', $secret)->first()) {
         return $this->createNewSecret($times + 1);
     }
     return $secret;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function match($user_id, $match_id)
 {
     $tournaments = Tournament::selectRaw('CONCAT(name, " (", start_date, ")") as name, tournament_id')->where('start_date', '>=', '2016-10-01')->orderBy('start_date', 'desc')->lists('name', 'tournament_id');
     $user = User::find($user_id);
     return view('pages/tools.referee.match', compact('tournaments', 'user', 'match_id'));
 }
Esempio n. 13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     echo $id;
     Tournament::destroy($id);
     return $this->index();
     // methoden parameter request apramter
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tournaments')->delete();
     Tournament::create(['name' => 'Dota Pit League Season 3', 'organizer' => 'Dota Pit', 'start_date' => '2015-01-21', 'end_date' => '2015-07-12', 'location' => 'online', 'format' => 'Groups into Double-elimination Bracket', 'prize_pool' => '$265,378+', 'status' => 'concluded']);
 }
Esempio n. 15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Tournament $tournament)
 {
     $tournament->delete();
     return redirect("tournaments");
 }