/** * Delete a resource * * @param mixed $id * @return ApiProblem|mixed */ public function delete($id) { if (!$this->userService->isAdmin()) { return new ApiProblem(403, 'Only admin can delete clients.'); } return $this->repository->delete($id); }
/** * Delete a resource * * @param mixed $id * @return ApiProblem|mixed */ public function delete($id) { $user = $this->userRepository->findByUsername($this->getIdentity()->getRoleId()); if ($user->getRole() != "admin") { return new ApiProblem("403", "The user has not access to this info."); } return $this->repository->delete((int) $id); }
/** * Delete a resource * * @param mixed $id * @return ApiProblem|mixed */ public function delete($id) { $userRepository = $this->repository->getUsersRepository(); $user = $userRepository->findByUsername($this->getIdentity()->getRoleId()); if ($user->getRole() == "admin") { return $this->repository->delete($id); } return new ApiProblem(403, 'Sem autorização para criar'); }
/** * Delete a resource * * @param mixed $id * @return ApiProblem|mixed */ public function delete($id) { try { $this->authService->hasRole('admin'); return $this->repository->delete($id); } catch (\Exception $e) { return new ApiProblem($e->getCode(), $e->getMessage()); } }
/** * Delete a resource * * @param mixed $id * @return ApiProblem|mixed */ public function delete($id) { $usuarioLogado = $this->getUsuarioLogado(); if ($usuarioLogado->getRole() === 'admin') { $retorno = $this->repository->delete($id); return $retorno; } else { return new ApiProblem(403, "Apenas usuários 'admin' podem excluir produtos"); } }