/** * Fetch all or a subset of resources * * @param array $params * @return ApiProblem|mixed */ public function fetchAll($params = array()) { try { $this->authService->hasRole(['admin', 'salesman']); if ($this->authService->isAdmin()) { return $this->ordersService->findAll(); } else { return $this->ordersService->findAllBySalesman($this->authService->getUser()->getId()); } } catch (\Exception $e) { return new ApiProblem($e->getCode(), $e->getMessage()); } }