Example #1
0
     }
 });
 /**
  * @api {post} /champions Create a new champion
  * @apiName PostChampion
  * @apiVersion 1.0.0
  * @apiSuccess {Object} champion Champion created
  */
 $this->post('', function ($req, $res, $args) {
     $champion = new \Champion();
     $body = $req->getParsedBody();
     $champion->name = $body['name'];
     $champion->slug = $body['slug'];
     $champion->save();
     if ($champion) {
         return $res->withStatus(200)->write($champion->toJson());
     } else {
         return $res->withStatus(400)->write('{"error":"there was an error processing your request"}');
     }
 });
 /**
  * @api {put} /champions/:id Updates the champion with ID
  * @apiName UpdateChampion
  * @apiVersion 1.0.0
  * @apiSuccess {Object} champion Champion updated
  */
 $this->put('/{id}', function ($req, $res, $args) {
     $id = $args['id'];
     $champion = $req->getParsedBody();
     return json_encode($champion);
     $sql = "UPDATE champions SET 'name'=:name, 'bans'=:bans, 'games'=:games, 'wins'=:wins WHERE id=:id";