Please, if anyone has managed to create a SaaS project using Laravel and Multi-Tenancy (one domain instead of a subdomain, e.g., app.domainname.com) with Authentication, I need some advice. I have managed to read and watch some tutorials, but I'm still really confused about how to implement it.
I'm now at the point : where I have created the project and installed the Stancl\Tenancy package. I have done the first basic configuration, and I also have an idea to create a CentralUser table in the central database. It will have (tenant_id, email). The objective of this table is that every time a user logs in, I will know which tenant database I should connect them to. In every Tenant, there will be a Users table that will have user data (email, password, etc.).
- Will this approach really work?
- If the user is logged in, how do I make them only connected to their database?