Ejemplo n.º 1
0
 /**
  * Finds user by [[username]]
  */
 public function getUser($username)
 {
     if (!$this->_user) {
         $this->_user = Users::findOne(compact('username'));
     }
     return $this->_user;
 }
Ejemplo n.º 2
0
 public function __construct($config = [])
 {
     $this->_user = Users::findOne(['id' => Yii::$app->user->identity->id]);
     $this->username = $this->_user->username;
     $this->email = $this->_user->email;
     $this->old_avatar = $this->_user->avatar;
     $this->first_name = $this->_user->first_name;
     $this->last_name = $this->_user->last_name;
     $this->notifications = $this->_user->notifications;
     parent::__construct($config);
 }
 public function actionUser($user, $tournament)
 {
     $userModel = Users::findOne($user);
     $forecastStatus = Forecasts::getUserForecastStatus($tournament, $user);
     $forecast = new ArrayDataProvider(['allModels' => $forecastStatus, 'pagination' => false]);
     $winnersForecast = Top3TeamsForecast::find()->where(['id_tournament' => $tournament])->andWhere(['id_user' => $user])->with('team.idTeam')->orderBy(['forecasted_position' => SORT_ASC])->asArray()->all();
     $isFinished = Tournaments::findOne($tournament)->is_active == Tournaments::FINISHED;
     $winnersForecastDataProvider = new ArrayDataProvider(['allModels' => $winnersForecast, 'pagination' => false]);
     $data = ['forecast' => $forecast, 'user' => $userModel, 'winnersForecast' => $winnersForecastDataProvider, 'isFinished' => $isFinished];
     if ($isFinished) {
         $userTournamentModel = UsersTournaments::find()->where(['id_user' => $user])->andWhere(['id_tournament' => $tournament])->with('winnersForecast')->one();
         $data['winnersForecastDetails'] = implode('</br>', Top3TeamsForecast::getClarifications($user, $tournament));
         $data['totalAdditionalPoints'] = $userTournamentModel->calculateAdditionalPoints();
     }
     return $this->renderAjax('user', $data);
 }