HDTuto.com

PHP Laravel 5.6 get current user details


we always require getting current logged in user data in laravel 5.6 app. I will show you how to get current user data like name, id, email, address etc by using laravel auth. I 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. As you would like to get it.

So, we 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. So let's see both examples one by one.

Using Helper:

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

print($user->id);

print($user->name);

print($user->email);

Using Facade:

$user = Auth::user();

print($user->id);

print($user->name);

print($user->email);






March 1, 2018 | Category : PHP Laravel Laravel 5 Laravel 5.6
Related Posts