Exemplo n.º 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id_or_slug
  * @return Response
  */
 public function show($id_or_slug)
 {
     try {
         $question = $this->questionService->getQuestionBySlug($id_or_slug);
     } catch (QuestionServiceException $e) {
         if (is_numeric($id_or_slug)) {
             try {
                 $question = $this->questionService->getQuestionById($id_or_slug);
             } catch (QuestionServiceException $e) {
                 return Response::json(['error' => $e->getMessage()], 404);
             }
         } else {
             return Response::json(['error' => $e->getMessage()], 404);
         }
     }
     return Response::json($question->toArray(), 200, [], JSON_NUMERIC_CHECK);
 }