diff --git a/app/Http/Controllers/QuestionAnswerController.php b/app/Http/Controllers/QuestionAnswerController.php index fe015b0..f60c027 100644 --- a/app/Http/Controllers/QuestionAnswerController.php +++ b/app/Http/Controllers/QuestionAnswerController.php @@ -49,16 +49,25 @@ class QuestionAnswerController extends Controller public function store(Request $request) { // return $request; - $question = Question::find($request->question_id); + $question = Question::find($request["questionId"]); if ($question == null) { throw new NotFoundHttpException("Question not found."); } - $answer = $question->answers()->create($request->all()); + $answer = [ + "respondent_id" => $request["respondentId"], + "question_id" => $request["questionId"], + "text" => $request["text"], + "questionchoice_id" => $request["questionchoiceId"] + ]; + // $answer = $question->answers()->create($request->all()); + // $answer = $question->answers()->create(["respondent_id" => $request["respondentId"]]); + $response = $question->answers()->create($answer); + // return $this->response // ->item($answer, new AnswerTransformer, ['key' => 'answers']); - return new AnswerResource($answer); + return new AnswerResource($response); } /**