public function init() { parent::init(); if (!Yii::$app->user->isGuest) { $user = Yii::$app->user; } else { $user = false; } if ($this->type == 'recent') { if ($user) { $this->_games = Games::getAllRecentGamesWithForecast($user->id); $this->_view = 'recentGamesUser'; } else { $this->_games = Games::getAllRecentGames(); $this->_view = 'recentGamesGuest'; } } else { if ($user) { $this->_games = Games::getAllFutureGamesWithForecast($user->id); $this->_view = 'futureGamesUser'; } else { $this->_games = Games::getAllFutureGames(); $this->_view = 'futureGamesGuest'; } } }