1

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

Marcelo Agimóvel
  • 1,668
  • 2
  • 20
  • 25

1 Answers1

1

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.

Marcelo Agimóvel
  • 1,668
  • 2
  • 20
  • 25
  • here is my question, Can you please check? https://stackoverflow.com/questions/47594676/laravel-passport-gives-401-unauthenticated-error?noredirect=1#comment82151397_47594676 – Nikhil Radadiya Dec 04 '17 at 06:59