### Install filament-teams via Composer Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/README.md Install the filament-teams package via Composer. The core package jeffersongoncalves/laravel-teams is pulled in automatically. ```bash composer require jeffersongoncalves/filament-teams:"^3.0" ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/README.md Run the test suite using Composer. ```bash composer test ``` -------------------------------- ### Configure FilamentTeamsPlugin with tenancy, invitations, resources, and tenantRoutePrefix Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/resources/boost/skills/filament-teams-development/SKILL.md Configure the Filament Teams plugin in a panel provider. Enable tenancy, invitations, and admin resources, and set the tenant route prefix to 'team'. ```php use JeffersonGoncalves\Filament\Teams\FilamentTeamsPlugin; FilamentTeamsPlugin::make() ->tenancy(true) ->invitations(true) ->resources(true) ->tenantRoutePrefix('team'); ``` -------------------------------- ### Publish and run teams migrations Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/README.md Publish and run the migrations for the teams feature. This provides the necessary tables, including the current_team_id column on the users table. ```bash php artisan vendor:publish --tag="teams-migrations" php artisan migrate ``` -------------------------------- ### Publish teams config file Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/README.md Publish the configuration file for the teams package. ```bash php artisan vendor:publish --tag="teams-config" ``` -------------------------------- ### Register FilamentTeamsPlugin in panel Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/README.md Register the plugin in your panel provider. The plugin automatically configures the panel tenant model, tenant registration page, tenant profile page, and tenant middleware. Options: tenancy (default true), invitations (default true), resources (default false), and tenantRoutePrefix. ```php use JeffersonGoncalves\Filament\Teams\FilamentTeamsPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentTeamsPlugin::make() ->tenancy() // enable tenant config (default: true) ->invitations() // register the invitation acceptance page (default: true) ->resources() // register the Teams & Team Invitations admin resources (default: false) ->tenantRoutePrefix('team'), ]); } ``` -------------------------------- ### Implement HasTeamsFilament trait and Filament tenancy contracts on User model Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/resources/boost/skills/filament-teams-development/SKILL.md Update the User model to use the HasTeamsFilament trait and implement the required Filament tenancy contracts. The users table must have a nullable current_team_id column, added by publishing and running the package migrations. ```php use Filament\Models\Contracts\FilamentUser; use Filament\Models\Contracts\HasDefaultTenant; use Filament\Models\Contracts\HasTenants; use JeffersonGoncalves\Filament\Teams\Concerns\HasTeamsFilament; class User extends Authenticatable implements FilamentUser, HasDefaultTenant, HasTenants { use HasTeamsFilament; } ``` -------------------------------- ### Configure Filament Teams Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/README.md Configuration array for the Filament Teams package. Set the guard, user model, personal teams flag, model classes, and table names. ```php return [ 'guard' => 'web', 'user_model' => 'App\Models\User', 'personal_teams' => true, 'models' => [ 'team' => \JeffersonGoncalves\Teams\Models\Team::class, 'team_invitation' => \JeffersonGoncalves\Teams\Models\TeamInvitation::class, 'membership' => \JeffersonGoncalves\Teams\Models\Membership::class, ], 'tables' => [ 'teams' => 'teams', 'memberships' => 'membership', 'team_invitations' => 'team_invitations', ], ]; ``` -------------------------------- ### Use HasTeamsFilament trait API methods on User Source: https://github.com/jeffersongoncalves/filament-teams/blob/3.x/resources/boost/skills/filament-teams-development/SKILL.md Access team relationships and operations on a user instance. Use these methods to retrieve owned teams, memberships, the current tenant, create a personal team, switch the active tenant, and check team membership or ownership. ```php $user->ownedTeams; // teams the user owns $user->teams; // teams the user is a member of $user->currentTeam; // current tenant $user->personalTeam(); // the auto-created personal team $user->switchTeam($team); // switch the active tenant (returns bool) $user->belongsToTeam($team); $user->ownsTeam($team); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.