Marcelo Agimóvel
Marcelo Agimóvel

Reputation: 1719

Laravel passport oauth multiple database connection

So, I'm building this api where each client use the same system (controllers, models). Each client has his own database and a website that connect's to this database.

Now that's the problem, this api must serve all this websites with different database connections and since I'm new to Laravel, I'm facing a hard time. What's the best way to do that?

Should I save each database in a file (for example client's id is 1, so we have a folder with a file named 1.env with database info)?

PS.: I'm using oauth2

Upvotes: 1

Views: 2433

Answers (1)

Marcelo Agimóvel
Marcelo Agimóvel

Reputation: 1719

The solution I found was: each client with his own database and a folder with "users" and a subfolder for each client. Inside, a file with database info, in login we use a global table that indicates where's the database from that user. Next step is load the database connection and check user/password. That was a quick solution.

However in my research I stumped into "multi tenancy" thing that seams way better, you can find it more on this link.

Upvotes: 1

Related Questions