added field on user model but can't get it for logged in user

i added a new column to the user table and model ‘office_id’ but when i try


its null (i am sure there is a value in the table)

I have added this to User model:


public function getOffice()


        return $this->hasOne(Office::className(), ['office_id' => 'office_id']);


I have other fields, like ->identity->role, ->identity->status that seem to work fine , but as i’ve just added this office_id, have I missed something ?

Have you cleared the schema cache?

any instructions u can link me on how to do so in yii2 ? cant seem to find anything obvious

It depends on your configuration where you are saving your cache.

If the console shares app’s cache configuration then you coluld use console command:

php yii cache/flush-schema

or just delete cache folder from ./runtime directory if using FileCache

hey there, just wanted to follow up - it must have been a cache issue, because i went away for the day and when i came back, turned on computer and it just started working as i expected :)