]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/TournamentController.php
simple result hiding on initial tournament request
[alttp.git] / app / Http / Controllers / TournamentController.php
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use App\Models\Tournament;
6 use Illuminate\Auth\Access\AuthorizationException;
7 use Illuminate\Http\Request;
8
9 class TournamentController extends Controller
10 {
11
12         public function single(Request $request, $id) {
13                 $tournament = Tournament::with(
14                         'rounds',
15                         'rounds.results',
16                         'participants',
17                         'participants.user',
18                 )->findOrFail($id);
19                 $this->authorize('view', $tournament);
20                 foreach ($tournament->rounds as $round) {
21                         try {
22                                 $this->authorize('seeResults', $round);
23                         } catch (AuthorizationException) {
24                                 $round->hideResults();
25                         }
26                 }
27                 return $tournament->toJson();
28         }
29
30 }