I have a problem with Laravel auth module.
I am rewriting old tool to laravel but have to keep old system DB structure.
System use multiple DBs (separated per department) and recognize which DB should be used by url, ex.
www.example.com/foo //use foo DB for foo department
www.example.com/bar //use bar DB for bar department
Foo and Bar DB have their own users table. There are some accounts that exist in both DBs but have different id, username is the same. Example:
//foo DB users table
ID username
1 xyz
2 abc
//bar DB users table
ID username
1 qwe
2 xyz
Let's say that I am logged in into system using foo deparment (and DB) as a user xyz (id 1).
I am switching now to bar department (and bar DB).
As a result I am logged in into bar department (and DB) as a user qwe because system keep using id (1) on which I've logged in into the system.
How to change that behaviour and force system to use username instead of id as a key to indetify user among DBs?
I know that i can use username as a primary key in users model but then I will have to change all relations connected with user model and also other things like Auth::id() etc.
Is there any easier way?