protected function onLoad()
 {
     if (!isset($_SESSION['userid'])) {
         $this->redirect('users', 'login');
     }
     if ($this->currentPlayer == null) {
         $this->currentPlayer = PlayerRepository::create()->getOne($_SESSION['userid']);
     }
     if ($this->currentUniversity == null) {
         $this->currentUniversity = UniversityRepository::create()->getOne($_SESSION['university_id']);
     }
     $this->view->playerName = $this->currentPlayer->getUsername();
     $this->view->university = $this->currentUniversity;
     $this->view->partial('authHeader');
 }
 public function save(Player $player)
 {
     $query = "\n            INSERT INTO players (username, password)\n            VALUES (?, ?)\n        ";
     $params = [$player->getUsername(), $player->getPassword()];
     if ($player->getId()) {
         $query = "UPDATE players SET username = ?, password = ? WHERE id = ?";
         $params[] = $player->getId();
     }
     $this->db->query($query, $params);
     return $this->db->rows() > 0;
 }