Search code examples
phplaravellaravel-5laravel-authentication

Laravel Authentication - Email in different table


I have two tables:

persons:

id   name   email   phone   person_type_id

users

id   person_id  password role_id etc...

Could you please tell me how to make Laravel's (5.8) built in Authentication System use the email field from persons table when authenticating a user? FYI, the value of guard provider has to be users.


Solution

  • You could create a custom user provider (which inherits from Illuminate\Auth\EloquentUserProvider) and override the retrieveByCredentials method.

    See Laravel Docs - The User Provider Contract