public function update(QuestionValidatedRequest $request, $question_id)
 {
     try {
         $updatedQuestion = $this->questionService->updateQuestion($request->all(), $question_id);
     } catch (QuestionServiceException $e) {
         return Response::json(['error' => ['message' => $e->getMessage()]], 404);
     }
     return Response::json($updatedQuestion->toArray(), 202, [], JSON_NUMERIC_CHECK);
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(QuestionValidatedRequest $request)
 {
     $data = $request->all();
     try {
         $data['user_id'] = Auth::user()->id;
         $question = $this->questionService->createQuestion($data);
     } catch (QuestionServiceException $e) {
         return Response::json(['all' => $e->getMessage()], 400);
     }
     return Response::json($question->toArray(), 200, [], JSON_NUMERIC_CHECK);
 }