Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sjoerrdd's avatar

Laravel auth multiple databases

Hello, At the moment I am (for school) working on an application with an extensive login option. The user chooses his school (dropdown), user name (input) and password (input). Based on the school, a connection is made to a different database (each school hosts its own database, that's how it says in the assignment). All students (users) are stored in this database, and they must now be logged in. How do I instruct the Auth facade to search for its data in another database?

0 likes
3 replies
Shahrukh4's avatar
Level 4

If you have multiple database to deal with, then all you need is the Multi-Auth system for your app which laravel can very easily manage. Try to go through the following references.

Medium Laravel Multi Auth

Package for Multi Auth

Like in the above references, if you manage the auth() for various database by creating various middlewares for each you can achieve that.

Please or to participate in this conversation.