How to get current authenticated user details using Auth in Laravel 5.6

In this article i share with you how to get current authenticated user details in Laravel 5.6. In many stages of our app we need Current authenticated user information like id, name. email etc..

Following method you can get current authenticated user details in controller and blade in same way.

You may access the authenticated user via the Auth facade (use Auth; or use Illuminate\Support\Facades\Auth;)

use Illuminate\Support\Facades\Auth;
$authenticated_user = Auth::user();
echo $authenticated_user->id;
echo $authenticated_user->name;
echo $authenticated_user->email;

// Get the currently authenticated user’s ID…

$userid = Auth::id();

using helper function you may access the authenticated user.

$currentuser = auth()->user();
echo $currentuser->id;
echo $currentuser->name;
echo $currentuser->email;

 

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *