public function showTournamentDetails(\Illuminate\Http\Request $request)
 {
     $tournamentID = $request->route('tid');
     try {
         $tournament = \App\Tournament::findOrFail($tournamentID);
     } catch (ModelNotFoundException $e) {
         \Session::flash('errorMsg', 'Tournament not found!');
         return \Redirect::back();
     }
     return \View::make('tournamentinfopage')->with('tournament', $tournament);
 }
Example #2
0
 /**
  * Joins tournament
  * @param $id Id of team, which should join tournament. Tournament is given within the input.
  * @return mixed redirection back with error or success msg
  */
 public function joinTournament($id)
 {
     $team = Team::findOrFail($id);
     if (Auth::user()->id == $team->captain->id || Auth::user()->hasRole('admin')) {
         $t = Tournament::findOrFail(Input::all()['tour_join_id']);
         foreach ($team->tournaments()->get() as $tournament) {
             if ($tournament->id == $t->id) {
                 return Redirect::back()->withErrors(trans('messages.tour-already-joined'));
             }
         }
         if (count($t->signedTeams()->get()) + 1 > $t->max_number_of_teams) {
             return Redirect::back()->withErrors(trans('messages.tour-full'));
         }
         //todo add datetime conditions
         $team->tournaments()->attach($t->id);
         return Redirect::back()->with('message', trans('messages.tour-joined'));
     } else {
         return Redirect::back()->withErrors(trans('messages.not-captain-or-admin'));
     }
 }
 /**
  * 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');
 }