My idea: I wanna to create an e-commerce app contains multi-tenants with multi-database, that's mean I have an admin panel for the main admin and another admin panel for tenants (vendor)
I installed the PK above the all things are fine!
My question:
How Can The Admin panel(main one) reach to the tenants data? like I need count the total products for all tenants and take some statistics for tenants!
Tenancy have some methods for that, to switch or set the connection to handle tenant's db. For example, Tenancy::getTenant(), setTenant($tenant),identifyTenant()...
For example, if you want retrieve the products data from a specific tenant, is something like:
public function getTenantProducts($tenant)
{
Tenancy::setTenant($tenant);
$product = App\Models\Tenant\Product::all();
}
@martinbean separating a multi-tenant application into multi-database helps with perfomance. Sometimes a single tenant might need more server resources than the rest of tenants so if everyone is under 1 bucket then everyone's perfomance is jeopardized because of 1 demanding tenant. Separating allows you to even allocate server resources as needed to each tenant and even bill them differently according to usage