Advertisement
krot

YII2 add user->identity variable

Apr 12th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. class User extends ActiveRecord implements \yii\web\IdentityInterface
  2. {
  3.     // Other code goes here...      
  4.     public function getFullname()
  5.     {
  6.         $profile = Profile::find()->where(['user_id'=>$this->id])->one();
  7.         if ($profile !==null)
  8.             return $profile->fullname;
  9.         return false;
  10.     }
  11. }
  12.  
  13. Yii::$app->user->identity->fullname;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement