How to get logged in user data into Laravel controller

Viewed 38785

I am working on laravel 5.4, i have used the auth for user login at client side,now i want the logged in user details at the Controller,

view side by writing below code i got that:

{{ Auth::user()->name }} // this works on view page only.

Suggest me the library files with the code. I want to display some user data like name,age,dob,etc after logged in.

8 Answers

Use the facade

use Illuminate\Support\Facades\Auth;

And

$user = Auth::user();

NOTE: You can call specific column in this library like $user = Auth::user()->name; or ->address etc.

$user = Auth::user();

You could get the current user into the user variable.

Related