@bartmommens I'm not sure if you've seen it, but if you haven't - https://laracasts.com/series/multitenancy-in-practice is a good series to follow covering multitenancy
Laravel Multi-tenancy approach advice.
Hello all,
I'm currenly planning on creating a SaaS project in Laravel in combination with the following packages: Laravel Fortify, Sanctum and Spatie's Multi-tenancy https://spatie.be/docs/laravel-multitenancy/v2/introduction.
I'm currently trying to wrap my head around a few points and could use some insights or advice. there is a landlord database that links a subdomain to a database and contains some roles and permissions for tenant apps. (some extra tables might be added over time). Each tenant has it's own database and subdomain with a login system.
The idea would be to manage the landlord data from the Admin application and retreive the info in the tenant application. (access throught the landlord database).
Most solutions out there tend to weave the landlord application inside the rest of the saas package which is easier to maintain but with some limitations like: Both apps must live on the same domain and share some common routes. Some conflicts might occure with Laravel Fortify routes and other package configurations.
Because of some complications i was thinking about creating a separate Laravel Project to manage the landlord database. But this also has a few downsides. For example both applications have shared models like tenant settings ( link domain -> database), roles and permissions for tenant apps, an both applications have a shared database (landlord). This is a bit harder to manage in 2 applications. Creating a package for the models and using it in both apps reduces the chances of model mismatches, but i don't know if this is a good approach. And also the APP_KEY issue if some encryption is required (for example contact person's email address or sensitive data) The Admin App should have a "Shared APP_KEY".
But it also has some advantages like launching a copy SaaS app on a different server can be connected by adding a new database connection to the admin application
Currently doubting myself if it's considered a bad practice / bad design to have to have a separate package to control the Landlord database and another on to read it.
For this reason i'm reaching out to get some advice or thoughts on this approach. All feedback is welcome and greatly appreciated
Thank you for taking your time to read this and sorry if it's a bit chaotic i'm having trouble translating my toughts into words ;)
Greets, Bart
Please or to participate in this conversation.