/** * @param $id * @return \Illuminate\Http\JsonResponse */ public function show($id) { $input = \Input::get('format', 'json'); $array = []; $recipe = $this->recipe->getRecipe($id); if ($recipe) { $category = $this->category->getCategory($recipe->category_id); $array = ['id' => $recipe->recipe_id, 'title' => $recipe->title, 'problem' => $recipe->problem, 'category' => ['description' => $category->description, 'name' => $category->name]]; } // render for hypermedia if ($input == 'hal') { $this->hal->setUri(route('home.recipe', ['one' => $id])); $this->hal->setData($array); $array = $this->hal; } return $this->render($array, $input); }