/** * Show the form for creating a new resource. * * @return Response */ public function answer(Request $request, Test $Test, Question $Question) { foreach ($request->input('answers', []) as $answer) { $Answer = Answer::find($answer); $Test->answers()->attach($Answer); } return redirect(route('client.test', $Test)); }