Laravel身份验证为什么我从其他模型或数据库表获取数据,但在模型本身却不能?
问题是,当我尝试使用SuiteSpecialist登录时,它不会使用SuiteSpecialist数据库表中的凭据登录。然而,当我使用SuiteSpecialist登录表单中blogger数据库表中的凭据时,它将登录 真奇怪 注:blogger登录正常,仅SuiteSpecialist登录即可,我可以注册数据并将其存储到SuiteSpecialist数据库表中 这是我的博客模式Laravel身份验证为什么我从其他模型或数据库表获取数据,但在模型本身却不能?,laravel,authentication,eloquent,model,laravel-6,Laravel,Authentication,Eloquent,Model,Laravel 6,问题是,当我尝试使用SuiteSpecialist登录时,它不会使用SuiteSpecialist数据库表中的凭据登录。然而,当我使用SuiteSpecialist登录表单中blogger数据库表中的凭据时,它将登录 真奇怪 注:blogger登录正常,仅SuiteSpecialist登录即可,我可以注册数据并将其存储到SuiteSpecialist数据库表中 这是我的博客模式 class Blogger extends Authenticatable { use Notifiable;
class Blogger extends Authenticatable
{
use Notifiable;
protected $guard = 'blogger';
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
class Suitspecialist extends Authenticatable
{
use Notifiable;
protected $guard = 'suitspecialist';
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
SuiteSpecialist车型
class Blogger extends Authenticatable
{
use Notifiable;
protected $guard = 'blogger';
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
class Suitspecialist extends Authenticatable
{
use Notifiable;
protected $guard = 'suitspecialist';
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
博主的登录控制器
public function showBloggerLoginForm()
{
return view('auth.login', ['url' => 'blogger']);
}
public function bloggerLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:6'
]);
if (Auth::guard('blogger')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) {
return redirect()->intended('/blogger');
}
return back()->withInput($request->only('email', 'remember'));
}
SuiteSpecialist的登录控制器
public function showSuitspecialistLoginForm()
{
return view('auth.login', ['url' => 'suitspecialist']);
}
public function suitspecialistLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:6'
]);
if (Auth::guard('suitspecialist')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) {
return redirect()->intended('/suitspecialist');
}
return back()->withInput($request->only('email', 'remember'));
}
在
config/auth.php
中检查“model”属性。我认为它设置为“blogger”。将其更改为用于身份验证的型号。Bro我尝试了两天的调试。问题解决了,谢谢!爱啊哈哈哈