Add a new attribute in Auth::user() session in Laravel 5.3

Posted 2 years ago by ashishsanjayrao

Hi,

I wanted to add a new attribute "first_name" in my Auth::user() so I can globally access it via Auth::user()->first_name.

The first_name column is not in my users table. It's in user_details table. I tried using Auth::user()->setAttribute('first_name', $first_name); where I'm getting the first name value successfully. But the "setAttribute" isn't working.

I'm not sure if "setAttribute" still works in Laravel 5.3 but I've used it in previous versions.

Would be great if anybody could tell me how I can achieve this.

Thanks!

Please sign in or create an account to participate in this conversation.