如何将用户数据登录到Laravel控制器中 [英] How to get logged in user data into Laravel controller
本文介绍了如何将用户数据登录到Laravel控制器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用laravel 5.4,我已经在客户端使用auth进行用户登录,现在我想在Controller上登录用户的详细信息,
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.
推荐答案
laravel Auth
Facade用于获取经过身份验证的用户数据
The laravel Auth
Facade is used to get the autheticated user data as
$user = Auth::user();
print_r($user);
这将在您的控制器中工作并查看两者,但您必须将其包括为
This will work in your controller and view both, but you have to include it as
use Illuminate\Support\Facades\Auth;
这篇关于如何将用户数据登录到Laravel控制器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文