When building a B2B SaaS platform in Laravel—whether managing multi-branch car showrooms, clinics, or enterprise portals—your earliest architectural decision is how to isolate tenant data. Both single-database (shared schema with tenant_id) and multi-database (isolated database per tenant) approaches work cleanly at 10 tenants. At 500 tenants, the wrong choice creates severe operational friction.
tenant_id Scoping)Every tenant shares the same database and tables. Isolation is enforced at the application layer via Laravel Global Scopes and automatic model observers.
// app/Models/Scopes/TenantScope.php
class TenantScope implements Scope{
public function apply(Builder $builder, Model $model): void{
if ($tenantId = app(TenantManager::class)->id()){
$builder->where($model->getTable() . '.tenant_id', $tenantId);
}
}
}
Where it shines:
Instant onboarding: Creating a tenant is a single INSERT into tenants.
Fast deployments: Schema migrations run once on a single database in seconds.
Cross-tenant analytics: Super-admin reporting across all tenants requires standard SQL queries.
The hidden traps:
Data leak risk: Raw queries (DB::table(...)), forgotten withoutGlobalScopes(), or misconfigured queue jobs can expose data across tenants.
Noisy neighbor problem: One tenant running a massive export query spikes CPU/IOPS for everyone else.
Composite indexing overhead: Every single index must lead with tenant_id (e.g., INDEX(tenant_id, status, created_at)), or MySQL falls back to scanning large index ranges.
Packages like stancl/tenancy dynamically switch Laravel’s default database connection (DB::setDefaultConnection(...)) based on the incoming subdomain or API token.
Where it shines:
Hard isolation: Accidental cross-tenant data leaks via SQL become structurally impossible.
Point-in-time recovery: Restoring a single tenant who accidentally deleted their catalog doesn't require rolling back other customers.
Compliance & enterprise readiness: Enterprise clients frequently demand physical data isolation and custom backup retention.
The hidden traps:
Migration bottlenecks: Running php artisan tenants:migrate across 2,000 databases can turn a 2-second deploy into a 15-minute pipeline bottleneck.
Connection pool exhaustion: PHP workers opening connections to hundreds of distinct databases can overwhelm MySQL max_connections unless you place ProxySQL or PgBouncer in front of the database.
Start with Single-Database if you are targeting high-volume SMBs with uniform schemas and rapid iteration. Choose Multi-Database (or a hybrid model where enterprise tiers get dedicated databases) when compliance, per-tenant backups, or heavy per-tenant write loads outweigh deployment simplicity.