Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pdellepiane's avatar

Auth set Session

Hello, My Users table has more columns than the default one. For example, it has a picture column. I would like to add that column at the Auth::user(), so that I can use it everywhere in my project. Does anybody know where to modify that?

Thanks in advance!

0 likes
4 replies
vtalbot's avatar

Auth::user() returns you an instance of a user from your users table. So, you should already have access to the new column.

1 like
jhoff's avatar
jhoff
Best Answer
Level 14

@pdellepiane You will have to use a database migration to add fields to your user table. Once they are added to the user table in the database, they will automatically be available on the User model. Nothing extra to do there.

If you have attributes that you want on the User model but not in the database, then you can add them by adding a getFooAttribute method to the User model, where Foo is replaced with the name of the attribute.

So lets assume you have a first_name and last_name columns in your user table, and you want Auth::user()->name to return the users full name:

public function getNameAttribute()
{
    return $this->first_name . ' ' . $this->last_name;
}

So all of the columns in your user table are automatically available as properties, but by defining custom attribute getters like the one above, you can add properties to the model that return whatever you want without the need to have an extra column in your table.

1 like

Please or to participate in this conversation.