]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/TournamentController.php
simple result hiding on initial tournament request
[alttp.git] / app / Http / Controllers / TournamentController.php
index c5bd40d84febb55ef3cb5fd3c632ee6c9f6e52b9..e563eac60bfb39c34a58e8da3da5a712a6ad14a6 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\Tournament;
+use Illuminate\Auth\Access\AuthorizationException;
 use Illuminate\Http\Request;
 
 class TournamentController extends Controller
@@ -16,6 +17,13 @@ class TournamentController extends Controller
                        'participants.user',
                )->findOrFail($id);
                $this->authorize('view', $tournament);
+               foreach ($tournament->rounds as $round) {
+                       try {
+                               $this->authorize('seeResults', $round);
+                       } catch (AuthorizationException) {
+                               $round->hideResults();
+                       }
+               }
                return $tournament->toJson();
        }