/**
  * The add action
  */
 public function addAction()
 {
     $auth = $this->session->get('auth');
     if ($auth) {
         $this->_bc->add('Add', 'awards/add');
         $allEpisodes = Episodes::find(array('order' => 'air_date DESC'));
         $allUsers = Users::find(array('order' => 'username'));
         $allPlayers = Players::find(array('order' => 'active DESC, name'));
         $this->view->setVar('users', $allUsers);
         $this->view->setVar('episodes', $allEpisodes);
         $this->view->setVar('players', $allPlayers);
         if ($this->request->isPost()) {
             $datetime = date('Y-m-d H:i:s');
             $award = new Awards();
             $award->userId = $this->request->getPost('user_id', 'int');
             $award->episodeId = $this->request->getPost('episode_id', 'int');
             $award->playerId = $this->request->getPost('player_id', 'int');
             $award->award = $this->request->getPost('award', 'int');
             if (!$award->save()) {
                 foreach ($award->getMessages() as $message) {
                     $this->flash->error((string) $message);
                 }
             } else {
                 $this->view->disable();
                 $this->flash->success('Award created successfully');
                 $this->invalidateCache();
                 $this->response->redirect('awards/');
             }
         }
     }
 }
 /**
  * get Action - gets data back
  */
 public function getAction()
 {
     $this->view->setRenderLevel(View::LEVEL_LAYOUT);
     // Invalidate the cache
     $results = $this->cache->get($this->getCacheHash('model'));
     if ($results === null) {
         $players = Players::find();
         if (count($players) >= 0) {
             foreach ($players as $player) {
                 $results[] = array('id' => $player->id, 'name' => $player->name, 'active' => $player->active, 'active_text' => $this->transformActive($player->active));
             }
         }
         $results = json_encode(array('results' => $results));
         $this->cache->save($this->getCacheHash('model'), $results);
     }
     echo $results;
 }