Exemplo n.º 1
0
 /**
  * Delete a Country
  */
 public function deleteAction()
 {
     $trainers = Trainer::getById($this->getRequest()->getParam('id'));
     if ($trainers) {
         if ($this->getRequest()->isPost()) {
             $trainers->delete();
             $this->Member->log('Delete: ' . $trainers->first_name . ' ' . $trainers->last_name . '(' . $this->getRequest()->getParam('id') . ')', 'Trainers');
             My_Plugin_Libs::setSplash('Posts: <b>' . $trainers->first_name . ' ' . $trainers->last_name . '</b> have been delete.');
             $this->_redirect($this->_helper->url('index', 'trainers', 'admin'));
         }
         $this->view->trainers = $trainers;
     }
 }
Exemplo n.º 2
0
    $body = $app->request->getBody();
    $json = json_decode($body);
    $trainer = Trainer::getById($id);
    $result = $trainer->removeBadge($json->badgeId);
    sendResponse($result);
});
$app->get('/trainers/:id', function ($id) use($app) {
    $trainer = Trainer::getById($id);
    sendResponse($trainer->serialize());
});
$app->get('/trainers/:id/pokemon', function ($id) use($app) {
    $trainer = Trainer::getById($id);
    sendResponse($trainer->getPokemon());
});
$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());
Exemplo n.º 3
0
 public static function create($name, $rivalId, $pokemon, $badgeIds)
 {
     if ($rivalId == null) {
         $rivalId = "NULL";
     }
     $result = Database::query(SQL::createTrainer($name, $rivalId));
     if ($result) {
         $lastId = mysqli_insert_id(Database::sharedDB());
         $trainer = Trainer::getById($lastId);
         foreach ($pokemon as $p) {
             $trainer->addPokemon($p->pokemonId, $p->pokemonLevel);
         }
         foreach ($badgeIds as $id) {
             $trainer->addBadge($id);
         }
         return Trainer::getById($lastId)->serialize();
     }
     return false;
 }