public function __construct() { //-- Get the days we have matches and check if today is a Match Date. $this->match_dates = json_decode(_MATCH_DAYS, true); $day_of_the_week = date('w'); @($match_day_info = $this->match_dates[$day_of_the_week]); if (!is_null($match_day_info)) { //-- Today is a Match Date $venue_id = $match_day_info["venue_id"]; $this->venue = Venue::getById($venue_id); $this->current_match = $this->getOrCreateMatchForToday(); //-- Check if the number of players for this match is already the max. $this->players_missing = $this->venue->getMaxPlayers() - $this->current_match->getPlayerCount(); if ($this->players_missing == 0) { //-- We cannot add more people to this match, so the status is full $this->match_status = self::STATUS_FULL; } else { //-- We still can add some players $this->match_status = self::STATUS_LFM; } //-- Check if the status is the same in BBDD now if ($this->current_match->getStatus() != $this->match_status) { //-- Discrepancy. Update BBDD $this->current_match->setStatus($this->match_status); $this->current_match->persist(); } //-- Get Players } }
public static function addMoreInfoToMatch(&$matchArray) { //-- Add Venue Info $venue_id = $matchArray["venue_id"]; $venue_info = Venue::getById($venue_id); $matchArray["venue"] = $venue_info->toArray(); return $matchArray; }