skip to Main Content
Laravel 5.5 Get Current Login User Detail

Laravel 5.5 get current login user detail

Laravel is the object-oriented PHP Framework. Laravel provides awesome auth functionality. Using Auth we can perform all user related operations. Today we are learning how to get the current login user detail using Auth.

Laravel provides Helper and Facades for getting current login user detail using Auth. let’s see both ways how we can get the current login user detail.

Using Facades we can get the current login user detail like

use Illuminate\Support\Facades\Auth;

// Get the currently authenticated user
$user = Auth::user();

$userId = $user->id;
$userEmail = $user->email;
$userName = $user->name;

echo '<pre>';
print_r($user);

// Get the currently authenticated user's ID...
$id = Auth::id();

Using Helper we can get the current login user detail like

// Get the currently authenticated user
$user = auth()->user(); $userId = $user->id; $userName = $user->name; $userEmail = $user->email; echo '<pre>'; print_r($user);

If you face any issue with getting the current login detail write the comment below.

Always welcome for the best suggestion or improvement write the comment.

Saroj

I am a web designer and developer part-time blogger. Write something on some free time. Find my every day thought here :)

Leave a Reply

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

Back To Top