Pavel Prokofiev
Pavel Prokofiev

Reputation: 449

How to get Laravel model of authorized user?

How can I get the user model in Laravel like this?

$userModel::find( auth()->id() );

I mean, auth user instance is already loaded, but in what above do we do the request to db...

Upvotes: 2

Views: 620

Answers (2)

Vikash
Vikash

Reputation: 3551

You can get loggedIn user info like below

$user = auth()->user() ? auth()->user() : null;

Upvotes: 0

Josh
Josh

Reputation: 1804

You can just do:

auth()->user();

or using the Auth facade:

Auth::user();

Upvotes: 2

Related Questions