Last active
December 20, 2015 11:49
-
-
Save crisu83/6126696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Web user component with support for loading the associated model. | |
* | |
* You can request attributes on the model object the following way: | |
* Yii::app()->user->model->username; | |
*/ | |
class WebUser extends CWebUser | |
{ | |
/** | |
* @var string the name of the associated model class. | |
*/ | |
public $modelClass = 'User'; | |
/** | |
* Returns the associated model for the logged in user. | |
* @return CActiveRecord | |
*/ | |
public function getModel() | |
{ | |
return !$this->isGuest ? CActiveRecord::model($this->modelClass)->findByPk($this->id) : null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment