Ejemplo n.º 1
0
 public function __construct($data)
 {
     if (is_array($data)) {
         $this->id = $data['gym_id'];
         $this->name = $data['gym_name'];
         $this->city = $data['gym_city'];
         $type = Type::getById(intval($data['gym_type']));
         $this->type = $type->serialize();
         $badge = Badge::getById(intval($data['gym_badge']));
         $this->badge = $badge->serialize();
     }
 }
Ejemplo n.º 2
0
});
$app->get('/trainers/:id/badges', function ($id) use($app) {
    $trainer = Trainer::getById($id);
    sendResponse($trainer->getBadges());
});
$app->get('/gyms', function () use($app) {
    sendResponse(Gym::getAll());
});
$app->get('/gyms/:id', function ($id) use($app) {
    $gym = Gym::getById($id);
    sendResponse($gym->serialize());
});
$app->get('/gyms/:id/leader', function ($id) use($app) {
    $gym = Gym::getById($id);
    sendResponse($gym->getLeader()->serialize());
});
$app->get('/types', function () use($app) {
    sendResponse(Type::getAll());
});
$app->get('/types/:id', function ($id) use($app) {
    $type = Type::getById($id);
    sendResponse($type->serialize());
});
$app->get('/badges', function () use($app) {
    sendResponse(Badge::getAll());
});
$app->get('/badges/:id', function ($id) use($app) {
    $badge = Badge::getById($id);
    sendResponse($badge->serialize());
});
$app->run();