Skip to main content

Introduction

Filament’s tenancy features allow you to build multi-tenant applications where users can belong to one or more organizations, teams, or accounts. Resources and data are automatically scoped to the current tenant.

Configuring tenancy

Enable tenancy by specifying the tenant model:
This enables multi-tenancy with the Team model as the tenant.

Tenant slug attribute

By default, Filament uses the model’s route key. Specify a custom slug attribute:

Ownership relationship

Define the relationship between users and tenants:
This assumes your User model has a team() relationship.

Tenant routing

Route prefix

Add a route prefix for tenant URLs:
URLs will be formatted as /team/{tenant}/admin.

Tenant domains

Use subdomains for tenants:
Each tenant gets their own subdomain: acme.example.com, widgets.example.com, etc.
When using tenant domains, ensure your web server and DNS are configured to handle wildcard subdomains.

Tenant model setup

Your tenant model should define the relationship to users:

User model setup

Your User model needs to define which tenants they can access:

Scoping resources to tenants

Resources are automatically scoped to the current tenant if they belong to one.

Enabling tenant scoping

Implement the tenant ownership relationship on your model:
Filament automatically scopes queries:

Custom tenancy scope name

If your relationship isn’t named after the tenant model:
Specify it in the panel:

Disabling automatic scoping

Optionally disable automatic scoping for specific resources:

Tenant switcher

The tenant switcher allows users to switch between tenants.

Customizing the switcher

Hiding the tenant menu

Tenant registration

Allow users to create new tenants:
Register the page:

Tenant profile

Allow users to edit tenant settings:
Register the page:

Tenant menu items

Customize the tenant menu dropdown:

Tenant billing

Integrate billing for tenants using a billing provider:
Implement the BillingProvider contract:

Requiring subscriptions

Require active subscriptions to access tenants:

Custom tenant resolution

Customize how tenants are resolved from route parameters:

Accessing the current tenant

Access the current tenant from anywhere:

Tenant-aware notifications

Notifications are automatically scoped to the current tenant when using database notifications.

Resource creation hooks

Automatically set the tenant when creating records:
Filament automatically handles this for you when your model has the correct tenant relationship defined.