Пример #1
0
 /**
  * Process PUT Requests. Updates an existing address.
  *
  * @param request Request to execute.
  *
  * @return Response Response to send.
  */
 public function put(Request $request)
 {
     $a = Address::fromArray($request->getBody());
     // TODO: improve error handling
     if ($this->addressService->updateAddress($a)) {
         return Response::ok();
     }
     return Response::notFound();
 }
Пример #2
0
 /**
  * Process POST Requests, which appends a new address to the collection.
  *
  * @param request Request to execute.
  *
  * @return Response Response to send.
  */
 public function post(Request $request)
 {
     $a = Address::fromArray($request->getBody());
     // TODO: improve error handling
     $id = $this->addressService->createAddress($a);
     if (!is_null($id)) {
         return Response::created("{$id}");
     } else {
         return Response::badRequest();
     }
 }