Person
id - integer
dni - string
name - string
User
id-interger
id_person integer
password-string
我有这两个表,我需要使用来自用户的dni和来自用户
的密码进行身份验证我尝试添加
public function username()
{
return 'dni';
}
在Auth / LoginController中,但无法正常工作 在我的config / auth.php中:
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
我怎样才能使用两个不同的表字段进行身份验证?
答案 0 :(得分:0)
你可以做到
$person = Person::where('dni', $dni)->first();
if (Auth::attempt(['id_person' => $person->id, 'password' => $password])) {
// Authentication passed...
}