コード例 #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)
 {
     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');
     }
 }
コード例 #4
0
ファイル: OrdersResource.php プロジェクト: netoudi/apigility
 /**
  * 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());
     }
 }
コード例 #5
0
 /**
  * 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];
 }
コード例 #6
0
 public function update($id, $data)
 {
     return $this->service->update($id, $data);
 }