### Install laravel-teams via Composer Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-teams ``` -------------------------------- ### Working with teams using HasTeams Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Example usage of the HasTeams trait methods for working with teams. ```php $user->ownedTeams; // Teams owned by the user $user->teams; // Teams the user belongs to $user->currentTeam; // The user's current team $user->personalTeam(); // The user's personal team $user->switchTeam($team); // Switch the current team $user->belongsToTeam($team); $user->ownsTeam($team); ``` -------------------------------- ### Publish and run migrations Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Publish and run the package migrations. ```bash php artisan vendor:publish --tag="teams-migrations" php artisan migrate ``` -------------------------------- ### Publish config file Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Optionally publish the config file. ```bash php artisan vendor:publish --tag="teams-config" ``` -------------------------------- ### Create and accept team invitations Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Create a team invitation and accept it. The accept method attaches the user and deletes the invitation. ```php use JeffersonGoncalves\Teams\Models\TeamInvitation; $invitation = TeamInvitation::create([ 'team_id' => $team->id, 'email' => 'invited@example.com', ]); $invitation->accept($user); // Attaches the user and deletes the invitation ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Run the package test suite. ```bash composer test ``` -------------------------------- ### Add HasTeams trait to User model Source: https://github.com/jeffersongoncalves/laravel-teams/blob/master/README.md Add the HasTeams trait to your User model. Requires a nullable current_team_id column on the users table (added by the published migration). ```php use Illuminate\Foundation\Auth\User as Authenticatable; use JeffersonGoncalves\Teams\Concerns\HasTeams; class User extends Authenticatable { use HasTeams; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.