Lets say, you are creating a web application, where you need your logged in customer’s user Id so that, you can show some links/or some specific features based on certain criteria. In such case, this tutorial is helpful for you. And yeah, sometimes we forget these small things and we try to Google it :).
In this how to guide, I am going to tell you, how you can easily get the logged in user’s details i.e. user Id, user name etc. Here it is:
Please note that I’m using Laravel 8 in this example.
$user = Auth::user(); echo $user->id; echo $user->name; echo $user->email;
Will output following:
1 Akhilesh [email protected]