예제 #1
0
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     $result = $this->ordersService->insert($data);
     if ($result == "error") {
         return new ApiProblem(405, 'Erro no processamento da Order');
     }
     return $result;
 }
예제 #2
0
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     $result = $this->service->insert($data);
     if ($result == "error") {
         return new ApiProblem(405, 'Error processing order');
     }
     return $result;
     //return new ApiProblem(405, 'The POST method has not been defined');
 }
예제 #3
0
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     try {
         $this->authService->hasRole(['admin', 'salesman']);
         $data->user_id = $this->authService->getUser()->getId();
         return $this->ordersService->insert($data);
     } catch (\Exception $e) {
         return new ApiProblem($e->getCode(), $e->getMessage());
     }
 }
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     if ($this->usersRepository->getAuthenticated()->getRole() != "salesman") {
         return new ApiProblem('405', 'The user has not access to this info.');
     }
     try {
         return $this->ordersService->insert($data);
     } catch (\Exception $e) {
         return new ApiProblem('405', 'Error processing order');
     }
 }
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     $userRepository = $this->repository->getUsersRepository();
     $user = $userRepository->findByUsername($this->getIdentity()->getRoleId());
     if ($user->getRole() != 'salesman') {
         return new ApiProblem(403, "Desculpe, você não tem permissão para cadastrar pedidos!");
     }
     $result = $this->service->insert($data);
     if ($result == "error") {
         return new ApiProblem(405, 'Erro ao processar Ordem');
     }
 }
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     $user = $this->usersRepository->findByUsername($this->getIdentity()->getRoleId());
     /*  if ($user->getRole() != "salesman") {
             return new ApiProblem("403", "The user has not access to this info.");
         }*/
     $orderId = $this->service->insert($data);
     if (!$orderId) {
         return new ApiProblem(500, 'Erro ao salvar ordem. ');
     }
     return ['orderId' => $orderId];
 }
예제 #7
0
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     $usuarioLogado = $this->getUsuarioLogado();
     if ($usuarioLogado->getRole() === 'salesman') {
         $result = $this->service->insert($data);
         if ($result === 'error') {
             return new ApiProblem(400, 'Erro ao inserir pedido');
         }
         return $result;
     } else {
         return new ApiProblem(403, "Apenas usuários 'salesman' podem adicionar pedidos");
     }
 }