App\Http\Controllers\ContestsController::show PHP Method

show() public method

public show ( $id )
    public function show($id)
    {
        $contest = Contest::findOrFail($id);
        $user = Auth::user();
        if (!$contest->visible && (!$user || !$user->isAdmin())) {
            abort(404);
        }
        if ($contest->isVotingStarted() && isset($contest->extra_options['children'])) {
            $contestIds = $contest->extra_options['children'];
        } else {
            $contestIds = [$id];
        }
        $contests = Contest::with('entries', 'entries.contest', 'entries.user')->whereIn('id', $contestIds)->orderByRaw(DB::raw('FIELD(id, ' . implode(',', $contestIds) . ')'))->get();
        if ($contest->isVotingStarted()) {
            return view('contests.voting')->with('contestMeta', $contest)->with('contests', $contests);
        } else {
            return view('contests.enter')->with('contestMeta', $contest)->with('contest', $contests->first());
        }
    }
ContestsController