Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
In this article, we will learn how to get current user details using auth helper in laravel application, there are many ways to get current login user data.
At first, we know some basic details about Auth in laravel.
Authentication is the process of identifying the user credentials. In laravel applications, laravel framework already provides auth for authentication, Authentication is managed by sessions that take the input parameters such as email or username, password, and google Id.
using Auth Facade we can easily get current Login user details.
Here, we have a user controller where we need some parameters of the current login user.
public function userDashboard()
{
$AuthData = Auth::user();
dd($AuthData);
return view('Frontend.user.dashboard');
}
This will work in your controller , but you have to include it :
use Illuminate\Support\Facades\Auth;
Now, you can pull what you want.
Here we can get all the parameters.
$AuthData->id;
$AuthData->name;
$AuthData->email;
$AuthData->role;
You can use using Auth Facade in mostly all laravel 5.6,5.8, 7, and 8 versions.
In this article, we learned “How to get current user details in Laravel”, I hope this article will help you with your Laravel Application Project.