In this tutorial you will learn about the Laravel 8 Get Current Logged in User Data Example and its application with practical example.
In this Laravel 8 Get Current Logged in User Data Example tutorial I will show you how to get current logged in user information in laravel 8 application. In this tutorial you will learn to get current logged in user data in laravel. In this article I will share various example to get user data like name, id, email, address etc. I will also show you how to get user data in laravel controller or blade files. We will use auth() helper and Auth facade class to get current user data.
Laravel 8 Get Current Logged in User Data Example
In this step by step tutorial I will demonstrate you how to get current logged in user data using auth helper or Auth facade.
Laravel Get Current User Data Using Auth Helper:
In this example I will show you how to get current user data using auth() helper:
1 2 3 4 |
$user = auth()->user(); var_dump($user->id); var_dump($user->name); var_dump($user->email); |
Output:-
1 2 3 |
10 Steve steve@yoursite.com |
Laravel Get Current User Data Using Auth Facade:
In this example I will show you how to get current user data using auth() facade:
1 2 3 4 |
$user = Auth::user(); var_dump($user->id); var_dump($user->name); var_dump($user->email); |
Output:-
1 2 3 |
10 Steve steve@yoursite.com |