我在Laravel 5.4中使用此代码来获取当前登录的用户ID
$id = User::find(Auth::id());
dd($id);
Run Code Online (Sandbox Code Playgroud)
但我收到"空"
除了我的 Laravel 项目中用户的电子邮件和密码之外,我还想向身份验证查询添加额外的条件
我在官方 Laravel 文档中读到了这个。 https://laravel.com/docs/5.6/authentication
指定附加条件 如果您愿意,除了用户的电子邮件和密码之外,您还可以向身份验证查询添加附加条件。例如,我们可以验证用户是否被标记为“活跃”:
Run Code Online (Sandbox Code Playgroud)if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1])) { // The user is active, not suspended, and exists. }
我在哪里可以找到这种方法?