Example #1
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));
 }
 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
 }
 /**
  * [find description]
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function find($id)
 {
     return Tournament::find($id);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $profile = "";
     $tournament = Tournament::find($id);
     return view('tournament.info', ['tournament' => $tournament]);
 }