Ejemplo n.º 1
0
 public function add(AddTeam $request)
 {
     $tournament = Tournament::findOrFail($request->input('team.tournament'));
     if (Tournament::STATUS_DRAFT !== $tournament->status) {
         throw new LogicException('Team can be assigned only to tournament with draft status.');
     }
     $team = TournamentTeam::create($request->input('team'));
     return $this->response->collection(TournamentTeam::where(['id' => $team->id])->get(), new TournamentTeamTransformer(), 'teams');
 }
Ejemplo n.º 2
0
 public function update($tournamentId)
 {
     /**
      * @var Tournament $tournament
      */
     $tournament = Tournament::findOrFail($tournamentId);
     $tournament->update(['name' => Input::get('tournament.name'), 'type' => Input::get('tournament.type'), 'status' => Input::get('tournament.status'), 'membersType' => Input::get('tournament.membersType'), 'description' => Input::get('tournament.description')]);
     return $this->response->collection(Tournament::where(['id' => $tournamentId])->get(), new TournamentTransformer(), 'tournaments');
 }
Ejemplo n.º 3
0
 public function register($id)
 {
     $tournament = Tournament::findOrFail($id);
     $user = Auth::user();
     if (!$tournament->isRegistrationOpen()) {
         return error_popup('registrations are closed!');
     }
     if (!$tournament->isValidRank($user)) {
         return error_popup('invalid rank!');
     }
     $tournament->register($user);
     return ujs_redirect("/tournaments/{$id}");
 }
 /**
  * Gets the desired model.
  *
  * @param $id
  *
  * @throws Illuminate\Database\Eloquent\ModelNotFoundException
  *
  * @return Model
  */
 public function get($id)
 {
     return Tournament::findOrFail($id);
 }