public function getForecastersListNew()
 {
     $forecasters = UsersTournaments::find()->where(['id_tournament' => $this->id_tournament])->with('idUser')->asArray()->all();
     $tours = Games::getNumberOfGamesPerTour($this->id_tournament);
     foreach ($forecasters as &$one) {
         $one['tours'] = Forecasts::getUserForecastTour($one['id_user'], $this->id_tournament, $tours);
     }
     return $forecasters;
 }
 public static function getAutoReminderRecipients($tournament, $tour)
 {
     $candidates = self::find()->joinWith('idUser')->where(['id_tournament' => $tournament, 'notification' => self::NOTIFICATION_ENABLED, 'active' => Users::STATUS_ACTIVE])->all();
     $recipients = [];
     $tours = Games::getNumberOfGamesPerTour($tournament);
     foreach ($candidates as $one) {
         if (Forecasts::getUserForecastTour($one['id_user'], $tournament, $tours)[$tour] != '2' && Reminders::ifEligible($tournament, $tour, $one['id_user'])) {
             $recipients[] = Users::find()->where(['id' => $one['id_user']])->one();
         }
     }
     return $recipients;
 }
 private static function sendReminder($tour, $tournament, $users)
 {
     $subject = "Напоминание: сделайте прогноз на матчи {$tour} тура турнира " . Tournaments::findOne($tournament)->tournament_name;
     $firstGameStarts = date('d-m-Y в H:i', ArrayHelper::getValue(Result::find()->select(['min(dtime) as dtime'])->where(['id_tournament' => $tournament, 'tour' => $tour])->all()[0], 'dtime'));
     $tours = Games::getNumberOfGamesPerTour($tournament);
     foreach ($users as $user) {
         if (Forecasts::getUserForecastTour($user->id, $tournament, $tours)[$tour] == 0) {
             $description = "Вы не сделали прогноз на матчи {$tour} тура турнира " . Tournaments::findOne($tournament)->tournament_name . ". Поторопитесь, первая игра тура начинается <strong>{$firstGameStarts}</strong>";
         } else {
             $description = "Вы сделали прогноз не на все матчи: {$tour} тура турнира " . Tournaments::findOne($tournament)->tournament_name . ". Поторопитесь, первая игра тура начинается {$firstGameStarts}";
         }
         $content = new ArrayDataProvider(['allModels' => Forecasts::getTourUserForecastStatus($tour, $tournament, $user->id), 'sort' => false, 'pagination' => false]);
         $messages[] = Yii::$app->mailer->compose('reminder', ['content' => $content, 'description' => $description, 'user' => $user])->setFrom([Yii::$app->params['adminEmail'] => 'Sportforecast'])->setTo($user->email)->setSubject($subject);
         //adding a record to the DB
         $reminder = self::getReminder($user->id, $tournament, $tour);
         $reminder->save();
     }
     if (!empty($messages)) {
         Yii::$app->mailer->sendMultiple($messages);
     }
     return true;
 }