/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update(EditRequest $request, $format_id, $question_id) { $this->question->fill($request->all()); $this->question->save(); $answers = $request->get('answers'); foreach ($answers as $id => $answer) { Answer::findOrFail($id)->fill($answer)->save(); } Flash::info('Pregunta Actualizada correctamente'); return redirect()->route('formats.observations.show', $this->format->id); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update(EditRequest $request, $protocol_id, $question_id) { $this->question->fillAndClear($request->all()); $this->question->save(); $this->question->answers()->update(['correct' => 0]); $answers = $request->get('answers'); $answers[$request->get('answers_correct')]['correct'] = 1; foreach ($answers as $id => $answer) { Answer::findOrFail($id)->fill($answer)->save(); } Flash::info('Pregunta Actualizada correctamente'); return redirect()->route('protocols.show', $this->protocol->id); }