> ## Documentation Index
> Fetch the complete documentation index at: https://docs.advancedtables.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-Tenancy

> Setup instructions for multi-tenancy using Filament's implementation or third-party packages like Spatie and Tenancy for Laravel.

### Setting up multi-tenancy with Filament's implementation

1. To set up multi-tenancy with Filament Panels and Filament's multi-tenancy implementation, first set up multi-tenancy in Filament per [Filament's instructions](https://filamentphp.com/docs/3.x/panels/tenancy).

2. After setting up tenancy in Filament, run the `AddTenancy` command:

   ```bash theme={null}
   php artisan advanced-tables:add-tenancy
   ```

   This command will add and run the necessary migrations to finishing setting up multi-tenancy in Advanced Tables.

### Setting up multi-tenancy with a third party implementation

1. To set up multi-tenancy with Filament Panels and [Spatie Multi-tenancy](https://spatie.be/docs/laravel-multitenancy/v3/introduction) or [Tenancy For Laravel](https://tenancyforlaravel.com/docs/v3/introduction) you will need to pass your `Tenant::class` to the `->tenant()` method of the `AdvancedTablesPlugin` object:

   ```php theme={null}
   AdvancedTablesPlugin::make()
       // Spatie
       ->tenant(\Spatie\Multitenancy\Models\Tenant::class)
       // TenancyForLaravel
       ->tenant(\Stancl\Tenancy\Database\Models\Tenant::class)
   ```

2. After setting up tenancy, run the `AddTenancy` command:

   ```bash theme={null}
   php artisan advanced-tables:add-tenancy
   ```

   This command will add and run the necessary migrations to finishing setting up multi-tenancy in Advanced Tables.

### Setting up multi-tenancy in Filament's standalone Table Builder with a third party implementation

1. To set up multi-tenancy with Filament's standalone Table Builder along with [Spatie Multi-tenancy](https://spatie.be/docs/laravel-multitenancy/v3/introduction) or [Tenancy For Laravel](https://tenancyforlaravel.com/docs/v3/introduction) you will need to add your `Tenant::class` to your `advanced-tables.php` config file:

   ```php theme={null}
   'tenancy' => [
       'tenant' => \Spatie\Multitenancy\Models\Tenant::class,
   ],
   ```

2. After you have configured your tenant model, you may proceed to run the `AddTenancy` command:

   ```bash theme={null}
   php artisan advanced-tables:add-tenancy
   ```

   This command will add and run the necessary migrations to finishing setting up multi-tenancy in Advanced Tables.
