public function vote($id) { $user = Auth::user(); $entry = ContestEntry::findOrFail($id); $contest = Contest::with('entries')->with('entries.contest')->findOrFail($entry->contest_id); priv_check('ContestVote', $contest)->ensureCan(); $contest->vote($user, $entry); return $contest->defaultJson($user); }
public function show($id) { $contest = Contest::with('entries')->with('entries.contest')->findOrFail($id); $user = Auth::user(); if (!$contest->visible && (!$user || !$user->isAdmin())) { abort(404); } if ($contest->isVotingStarted()) { return view("contests.voting.{$contest->type}")->with('contest', $contest); } else { return view('contests.enter')->with('contest', $contest); } }
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()); } }