public static function getEventsForTeam($teamId, $update = false) { if ($update) { require_once './eagle/utils/Downloader.php'; Downloader::getEventsForTeam($teamId); } $filename = './data/' . $teamId . '/events.json'; return self::readFile($filename); }
require_once './eagle/models/PitScouting.php'; $app->group('/team', function () { $this->get('/{url:.*\\/}', function ($req, $res, $args) { header('Location:/team/' . trim($args['url'], '/')); exit; }); $this->get('/{team:[0-9]{1,4}}', function ($req, $res, $args) { Auth::redirectIfNotLoggedIn(); $team = FileReader::getTeam($args['team']); if (!$team) { Downloader::getTeam($args['team']); header('Refresh:0'); } $events = FileReader::getEventsForTeam($args['team']); if (!$events) { Downloader::getEventsForTeam($args['team']); header('Refresh:0'); } $comments = Comment::where('team_id', $team->team_number); $defense = Defense::where('team_id', $args['team'])->orderBy('id', 'desc')->first(); $defenses = array(); $author = $defense ? $defense->author : false; if ($defense) { $defenses['Low Bar'] = $defense->low_bar; $defenses['Portcullis'] = $defense->portcullis; $defenses['Cheval de Frsie'] = $defense->cheval_de_frise; $defenses['Moat'] = $defense->moat; $defenses['Ramparts'] = $defense->ramparts; $defenses['Drawbridge'] = $defense->drawbridge; $defenses['Sally Port'] = $defense->sally_port; $defenses['Rock Wall'] = $defense->rock_wall;