[英]Laravel 5.3-5.4 The Difference between $request->user(); and Auth::user();
I was reviewing some of the code logic on my system and wondered about some things. 我正在查看系统上的一些代码逻辑,并对某些事情感到好奇。 After a person has logged onto the system you can either use
$request->user();
一个人登录系统后,您可以使用
$request->user();
or Auth::user();
或
Auth::user();
to get the user object. 获取用户对象。
My questions are: 我的问题是:
Thanks in advance, Cheers! 预先感谢,干杯!
Let me give you a brief description: 让我给你一个简短的描述:
Auth::user();
holds the credentials or you can say the information when a user logs into application using Auth
. 拥有凭据,或者当用户使用
Auth
登录应用程序时您可以说出这些信息。
When the user is logged successfully, it's credentials are stored in the form of cookies
or sessions
that are destroyed after logout. 成功登录用户后,其凭据将以
cookies
或sessions
的形式存储,并在注销后销毁。
No it is not pulled from database. 不,它不是从数据库中提取的。 The logged in user details are stored in
session
and pulled from there. 登录的用户详细信息存储在
session
然后从那里拉出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.