Laravel Get Auth User ID Example

10-Apr-2023

.

Admin

hi gusy

In this blog i will explain you can how to get current logged in user in laravel. i will show get current user id in controller, view files. you can user auth() helper and auth facade class to get current user data.

I will show you how to get current user data like id by using laravel .We will give you two way to get current user data using laravel authentication. you can simply get logged in user details in controller or view blade files.

I can get current user details using laravel auth. you can also use simple auth helper or Auth facade. So i will give you both example, you can take any one as you want.I always require getting current logged in user data in laravel.

Here the blow example of get auth user id in laravel

Example Using Facade


Now this example is using facade.

$user = Auth::user();

print($user->id);

Example Using Helper

Now this example is using facade.

$user = auth()->user();

print($user->id);

It will help you...

#Laravel 7

#Laravel

#Laravel 6