/**
  * Delete a resource
  *
  * @param  mixed $id
  * @return ApiProblem|mixed
  */
 public function delete($id)
 {
     $entity = $this->repository->find($id);
     $usuarioLogado = $this->getUsuarioLogado();
     if ($usuarioLogado->getRole() === 'admin' || $usuarioLogado->getId() === $entity['user_id']) {
         return $this->service->delete($id);
     }
 }
Example #2
0
 /**
  * Delete a resource
  *
  * @param  mixed $id
  * @return ApiProblem|mixed
  */
 public function delete($id)
 {
     try {
         $this->authService->hasRole('admin');
         return $this->ordersService->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->isOwnerOfOrder($id)) {
         return new ApiProblem("403", "The user has not access to this info.");
     }
     $result = $this->service->delete($id);
     if (!$result) {
         return new ApiProblem(500, 'Erro ao salvar ordem. ');
     }
     return $result;
 }
 /**
  * Delete a resource
  *
  * @param  mixed $id
  * @return ApiProblem|mixed
  */
 public function delete($id)
 {
     return $this->service->delete($id);
 }