/** * Store the attempt in the database * * @param App\Challenge $challenge * @param App\Http\Requests\StoreAttemptRequest $request * * @return response */ public function store(StoreAttemptRequest $request, Challenge $challenge) { $attempt = $challenge->attempts()->create(['user_id' => $request->user()->id, 'status' => 'IN_PROGRESS', 'stream' => $request->stream]); $challenge->attempts_counter += 1; $challenge->save(); return redirect()->route('attempts.show', [$attempt])->with('Success', 'Good luck!'); }
/** * Show the Challenge * * @param App\Challenge $challenge * * @return response */ public function show(Challenge $challenge) { return view('challenges.show', ['challenge' => $challenge, 'online_attempts' => $challenge->attempts()->where('online', 1)->get()]); }