public function getMatch($id) { $match = MatchModel::getMatch($id); if (empty($match)) { return array('error' => 'Match not found!'); } return array('match' => $match[0]); }
public function getDuration() { $matches = MatchModel::model('MatchModel')->findAll('match_id=? and win > 0', array($this->id)); foreach ($matches as $match) { $duration = intval($match->duration / 60); return $duration . '分钟'; } return 'unknown'; }
public function showTeam($id) { $team = TeamModel::getTeamById($id); if (empty($team)) { return View::make('error', array('error' => 'Team not found!')); } $teamMatches = MatchModel::getTeamMatches($id); return View::make('team', array('team' => $team, 'matches' => $teamMatches)); }
public function getMatches($season = '2016s2') { if (!isset($this->_matches[$season])) { $matches = array(); foreach (MatchModel::model('MatchModel')->with('info')->findAll('player_id=? and info.season=?', array($this->id, $season)) as $match) { $matches[$match->match_id] = $match; } ksort($matches); $this->_matches[$season] = $matches; } return $this->_matches[$season]; }
/** * Return only the last match played, with additional informations (teams and scores included) * * @return Match Object */ public static function getNextMatch() { $matchs = MatchModel::getNextMatchs(1); if (count($matchs) == 1) { $match = $matchs[0]; $matchId = $match->ID; $match->match_date = Meta::get($matchId, 'match_date'); $match->match_team_dom = Meta::get($matchId, 'match_team_dom'); $match->match_team_ext = Meta::get($matchId, 'match_team_ext'); return $match; } }
public function getPlayers() { $players = array(); $matches = MatchModel::model('MatchModel')->findAll('match_id=?', array($this->match_id)); foreach ($matches as $match) { if (!isset($players[$match->side])) { $players[$match->side] = array(); } $player = $match->player; $player->match = $match; $players[$match->side][] = $player; } return $players; }
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); }
/** * Called to delete our last scored goal * (mostly for goals with middle row players) */ public function deleteGoal() { $team = Session::get('team'); if (empty($team)) { return array('error' => 'You are not logged in!'); } // check if user is in some match, or his match finished in last 5 minutes $match = MatchModel::getActiveMatchForTeam($team->id, true); if (empty($match)) { return array('error' => 'You are not in match!'); } $match = $match[0]; // run this as transaction return DB::transaction(function () use($match, $team) { $forHomeTeam = $match->home_id == $team->id; // decrease our score MatchModel::deleteGoalOnMatch($match->id, $forHomeTeam); // update the teams goals counters, if the game was reopened if ($match->home_score == 10 || $match->away_score == 10) { $homeTeamWon = $match->home_score == 10; // if we try to delete goal if we didn't win if ($forHomeTeam != $homeTeamWon) { DB::rollback(); return array('error' => 'You can\'t delete goal in lost match!'); } MatchModel::updateTeamGoals($match->home_id, $match->away_id, $match->home_score, $match->away_score, true); } return array('status' => 'ok'); }); }
public function widget($args, $instance) { $match = MatchModel::getNextMatch(); echo "<h5>Prochain match</h6>" . "<h1>" . $match->match_team_dom . " - " . $match->match_team_ext . "</h1>"; }
public function index() { return View::make('home.home-content')->with(array('actus' => PostModel::all(), 'last_match' => MatchModel::getLastResult(10), 'next_match' => MatchModel::getNextMatchs(2), 'home_banner' => themosis_assets() . "/images/banner.jpg")); }