Esempio n. 1
0
 public static function getForecastResultUserTourTournament($user, $tour, $tournament)
 {
     $games = Result::getGamesTourTournament($tour, $tournament);
     $forecasts = self::find()->where(['and', "id_user = {$user}", ['in', 'sf_forecasts.id_game', ArrayHelper::getColumn($games, 'id_game')]])->asArray()->all();
     $forecasts = ArrayHelper::index($forecasts, 'id_game');
     $games = ArrayHelper::toArray($games);
     foreach ($games as &$one) {
         if (array_key_exists($one['id_game'], $forecasts)) {
             $one['fscore_home'] = $forecasts[$one['id_game']]['fscore_home'];
             $one['fscore_guest'] = $forecasts[$one['id_game']]['fscore_guest'];
             $one['fpoints'] = $forecasts[$one['id_game']]['points'];
             $one['status'] = true;
         } else {
             $one['fscore_home'] = '-';
             $one['fscore_guest'] = '-';
             $one['fpoints'] = '-';
             $one['status'] = false;
         }
     }
     ArrayHelper::multisort($games, 'dtime');
     return $games;
 }