How to access user information in index file

Hi All,

I’m new to Yii2 Framework. Let’s say I have added a new column named ‘Notes’ to table User.

I want to access this column ‘Notes’ after I logged in to the website in the view index file not in view User.

Please help.


Wilson IM

$user = (User)Yii::$app->user->getIdentity();

thanks for the reply. It is error.

What i mean is access $model->Notes from index view site controller, and i do not create User Controller yet.

A controller can handle any models in it.

For example, you may freely use User model or whatever you like in your Site controller.

could you give the example? Thanks

$user = (User)Yii::$app->user->getIdentity();

echo $user->Notes;

Thank you so much