/** * 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) { try { $this->authService->hasRole('admin'); return $this->productsRepository->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) { if ($this->repository->delete($id)) { return ['success' => true]; } else { return new ApiProblem(500, "Erro ao deletar o item: {$id}"); } //return new ApiProblem(405, 'The DELETE method has not been defined for individual resources'); }
/** * 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) { $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"); } }