Person
id - integer
dni - string
name - string
User
id-interger
id_person integer
password-string
i have this two tables, and i need authenticate with dni from Person and password from user
i tried adding
public function username()
{
return 'dni';
}
in Auth/LoginController, but not working In my config/auth.php :
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
how can I still authenticate with two different table fields?
You can do
$person = Person::where('dni', $dni)->first();
if (Auth::attempt(['id_person' => $person->id, 'password' => $password])) {
// Authentication passed...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.