public function login() { $team = Session::get('team'); if (empty($team)) { $team = TeamModel::getTeamByKey(Input::get('key')); if (empty($team)) { return array('error' => 'No team registered with this key!'); } $team = $team[0]; // put data into session Session::put('team', $team); } // check if there is match in progress $activeMatch = MatchModel::getActiveMatchForTeam($team->id); return array('team' => $team, 'match' => $activeMatch); }