Overview
Larafast Multi-Tenancy uses a shared database approach with logical data isolation. All tenants (teams) share the same database, and data is separated using team associations in your models and queries.Architecture Benefits
This approach provides:Cost Efficiency
- Single database infrastructure for all tenants
- No need to manage multiple database connections
- Reduced hosting and maintenance costs
Easier Maintenance
- One schema to manage and update
- Simplified migrations and deployments
- Single backup strategy
Better Resource Utilization
- Shared connection pooling
- More efficient use of database resources
- Better query caching opportunities
Simplified Operations
- One database to monitor and optimize
- Easier to scale vertically
- Simplified disaster recovery
Database Schema
The multi-tenancy system uses three core tables:Core Tables
teams- The tenant model (each team is a tenant)team_user- Pivot table managing team membershipsteam_invitations- Email-based team invitationsusers- Modified to includecurrent_team_id
How Data Isolation Works
Logical Separation
Data is isolated usingteam_id foreign keys on all tenant-scoped tables:
Global Scopes
Models use Eloquent global scopes to automatically filter queries:Automatic Assignment
When creating records,team_id is automatically set:
Next Steps
Learn about the specific database tables and their schemas:- Teams Table - The core tenant table
- Team User Table - Managing memberships
- Team Invitations Table - Invitation system
- Creating Tenant-Scoped Tables - Add your own tables

