> ## 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.

# Simple one-to-many tenancy

> Setup instructions for simple one-to-many tenancy with Filament Panels and standalone Table Builder.

Since in a [simple one-to-many tenancy](https://filamentphp.com/docs/3.x/panels/tenancy#simple-one-to-many-tenancy) implementation, each user only belongs to one tenant (*team, organization, company, etc.*), it may not be necessary to set up tenancy in Advanced Tables as each User View is already scoped to a user. However, if are allowing users to [share views](/v4/features/user-views#disabling-making-a-user-view-public) or if your tenant will have admins that can create [Global Favorite Views](/v4/features/user-views#enabling-making-a-user-view-a-global-favorite), you will need to enable tenancy so that each User View will be scoped to the appropriate tenant.

### Setting up simple tenancy with Filament Panels

1. To set up simple tenancy with Filament Panels you will need to pass your `Tenant::class` to the `->tenant()` method of the `AdvancedTablesPlugin` object:

   ```php theme={null}
   AdvancedTablesPlugin::make()
       ->tenant(Team::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.

### Setting up simple tenancy with Filament's standalone Table Builder

1. To set up simple tenancy with Filament's standalone Table Builder you will need to add your `Tenant::class` to your `advanced-tables.php` config file:

   ```php theme={null}
   'tenancy' => [
       'tenant' => App\Models\Team::class,
   ],
   ```

2. Inside your tenant model you need to include a `getTenantId()` method so Advanced Tables knows which tenant to use for its scopes:

   ```php theme={null}
   class Team extends Model
   {
       public function getTenantId(): ?string
       {
           return auth()->user()?->team_id;
       }
   }
   ```

3. After you have configured your tenant model and the `getTenantId()` method, 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.
