Today now in this post i will show you How to Get Logged in User Data in Laravel? If you are a beginner or don’t know how to get the logged in user details in laravel application. We can do this by using laravel auth helper. Laravel can get the current login user data both way one is by using auth helper and another one is by using Auth facade. Now in this post we will learn how to get the current logged user id.
So just you need to copy.
Get Logged User Data using helper
We can get the login user details by using auth() helper, it will return the object of users details.
$user = auth()->user(); print_r($user);
Get Logged User ID using helper
$id = auth()->user()->id; print_r($id);
Get Logged User Data using facade
We can also get login user details by using Auth facade, it will also return the object of users data.
$user = Auth::user(); print_r($user);
Get Logged User ID using facade
$id = Auth::user()->id; print_r($id);
Read Also : Laravel 8 Mobile Number Verification Tutorial
Thanks for read. I hope it help you. For more you can follow us on facebook