repository = $repository; } /** * @param $id * @return \Illuminate\Http\JsonResponse|mixed */ public function getById($id){ try{ $document = $this->repository->getBySlug(trim($id)); if(is_null($document)) $document = $this->repository->getById(intval($id)); if(is_null($document)) return $this->error404(); return $this->ok(SerializerRegistry::getInstance()->getSerializer ( $document )->serialize()); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array($ex1->getMessage())); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message'=> $ex2->getMessage())); } catch (Exception $ex) { Log::error($ex); return $this->error500($ex); } } }