/** * Fetch a resource * * @param mixed $id * @return ApiProblem|mixed */ public function fetch($id) { try { $this->authService->hasRole(['admin', 'salesman']); if ($this->authService->isAdmin()) { return $this->ordersService->find($id); } else { return $this->ordersService->findBySalesman($id, $this->authService->getUser()->getId()); } } catch (\Exception $e) { return new ApiProblem($e->getCode(), $e->getMessage()); } }