gpt4 book ai didi

authentication - Laravel:依赖注入(inject)身份验证

转载 作者:行者123 更新时间:2023-12-04 06:40:46 25 4
gpt4 key购买 nike

如何在 Laravel 中依赖注入(inject) Auth?

像这样:

 public function __construct(Auth $auth)
{
$this->auth = $auth;

}

如果我这样做,那么这不起作用:
$user_type = Auth::user()->user_type;

最佳答案

您应该输入提示 Illuminate\Auth\AuthManager :

public function __construct(Illuminate\Auth\AuthManager $auth)
{
$this->auth = $auth;
}

关于authentication - Laravel:依赖注入(inject)身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26759772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com