Support the ongoing development of Laravel.io →
Authentication Database Eloquent

I'm very new to Laravel and am currently building a multi-tenant app. Basically when anyone signs up for an account a new database along with tables, indexes and data gets created. I've managed to create these tables and also managed to switch dynamically between the default database and the account database to retrieve and insert data. I use Config::set() to basically switch between databases on the fly.

I'm currently stuck with user authentication. User signup works fine and all user credentials are stored in their respective account databases. So let's say account ABC has 3 users. Their email and password will be in "databaseabc". When a user wants to login, Auth should basically switch to the accountdb and check on the users table there (the default database has no users table). Passing parameters (database name, database username, database password) to AuthController is not a problem. I just need to know how to switch to it using the account database instead of the default one. I tried using Config::set() in AuthController but that didn't help.

Please let me know if anyone has any ideas about this.

Thank you.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.