Skip to main content

Overview

Larafast Multi-Tenancy uses Filament v4’s native multi-tenancy features configured in the panel providers. You’ll have two panels: the App panel (tenant-scoped) and the Admin panel (global).

App Panel Configuration

The main application panel is where multi-tenancy is configured for end-users. Location: app/Providers/Filament/AppPanelProvider.php

Basic Tenant Setup

Configuration Options

1. Tenant Model

  • Team::class - The model that represents your tenants
  • ownershipRelationship - Must match a method on User model that returns teams
The User model must have a teams() method:

2. Tenant Registration

  • Enables users to create new teams
  • Custom page for team creation
  • Users prompted to create team on first login
  • Remove this line to disable team creation

3. Tenant Profile

  • Custom page for editing team settings
  • Accessible from user menu dropdown
  • Can customize to show team-specific settings

4. Tenant Middleware

  • UpdateUserCurrentTeam - Updates user.current_team_id when switching
  • isPersistent: true - Middleware runs on every tenant-scoped request
  • Add your custom middleware here

5. Tenant Billing

  • tenantBillingProvider - Integrates with Stripe for subscriptions
  • requiresTenantSubscription(false) - Teams can be created without subscription
  • Set to true to require subscription before access

Complete Example

Admin Panel Configuration

The admin panel does NOT have multi-tenancy. Administrators can see and manage all teams. Location: app/Providers/Filament/AdminPanelProvider.php

Key Differences

Panel URLs

App Panel URLs

  • Dashboard: /app
  • With tenant: /app/teams/1/dashboard
  • Resources: /app/teams/1/projects

Admin Panel URLs

  • Dashboard: /admin
  • Resources: /admin/teams, /admin/users

Customizing Tenant URLs

By default, tenant IDs are used in URLs. You can use slugs instead:

Add Slug Column

Update Team Model

URLs Will Change

  • Before: /app/teams/1/dashboard
  • After: /app/teams/acme-corporation/dashboard

Next Steps