authorize('apply', $tournament); $application = new Application(); $application->tournament_id = $tournament->id; $application->user_id = $request->user()->id; $application->save(); ApplicationAdded::dispatch($application); return $tournament->toJson(); } public function single(Request $request, $id) { $tournament = Tournament::with( 'applications', 'applications.user', 'rounds', 'rounds.results', 'participants', '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(); } }