/**
  * 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;
 }
 /**
  * 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');
 }
 /**
  * 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');
     }
 }
Example #4
0
 /**
  * Update a resource
  *
  * @param  mixed $id
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function update($id, $data)
 {
     try {
         $this->authService->hasRole('admin');
         return $this->ordersService->update($id, $data);
     } catch (\Exception $e) {
         return new ApiProblem($e->getCode(), $e->getMessage());
     }
 }
 /**
  * Update a resource
  *
  * @param  mixed $id
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function update($id, $data)
 {
     if (!$this->isOwnerOfOrder($id)) {
         return new ApiProblem("403", "The user has not access to this info.");
     }
     $orderId = $this->service->update($id, $data);
     if (!$orderId) {
         return new ApiProblem(500, 'Erro ao salvar ordem. ');
     }
     return ['orderId' => $orderId];
 }
 public function update($id, $data)
 {
     return $this->service->update($id, $data);
 }