How to get current user details using Laravel 8
This tutorial is for How to get current user details using Laravel 8. Here, I will show you how to get the currently logged-in user in Laravel 8. We will use Laravel auth() helper and Auth facade class to get current user data.
I will show you How to get current user details like id, name, email, etc by using Laravel 8 auth and we always require getting current logged-in user data in the Laravel 8 application. Simply you get logged-in user details in the controller file or view blade files. You use Laravel auth helper or Auth facade.
- Helper
- Facade
Helper
$user = auth()->user();
print($user->id);
print($user->name);
print($user->email);
Facade
$user = Auth::user();
print($user->id);
print($user->name);
print($user->email);