I have been working in default authentication features in laravel..I found in one blade file Auth::user()->name is able to display name stored in user table..But what i want to know is how it is able display name in blade with an eloquent call.
-
`Auth` is the facade to access the auth manager, and `Auth::user` returs the authenticated user associated with the default guard. It is not an eloquent query (not directly anyway) so there's a logical disconnect between assumptions and assumed desired end result. – apokryfos Nov 05 '17 at 18:44
-
guys if any mistake in my question or u didnt understand my question plz let me know ..plz dont down vote .I may lose my account – siva sandeep Nov 05 '17 at 18:44
3 Answers
You can use it like this.
auth()->user()->some_column
Check your user table in your database and use the appropriate column name.
You can use it in blade file like this.
{{ auth()->user()->some_column }}
If you're going to use this in a conditional statement like IF, you can use it like this.
@if(auth()->user()->some_column)

- 625
- 7
- 8
You can use vanilla php for blade. Just do something like this {{ Auth::user()->email }}
to get email, {{ Auth::user()->id }}
to get id or {{ Auth::user()->some_column }}
to get some_column from user table in database from current authenticated user.
Laravel got a amazing documentation laravel docs and somthing good to learn is laracasts.com with video tutorials with Jeffrey Way.

- 369
- 1
- 2
- 10

- 670
- 6
- 23
It's very late, for for future -
These steps are supposed to be followed behind-
When you login using Auth
facade, the Auth::user()
connects to the default 'users'
table(which can be changed by referring to the documentation) and fetches all the data against the username or email whatever you used to authenticate the user.
After that, using Auth::user()->columnname
retrieves the data from the columnname
of the respective user (whose username/email was recognized above) and displays it. This data is made available to be used in blade tp be rendered.
The Auth::user()
disconnects from the database when the user logs out (command followed Auth::logout()
) and the above steps are repeated for re-login.

- 760
- 1
- 10
- 16