### Install Teams for Laravel with Composer and publish migrations Source: https://github.com/roundly-consulting/teams-for-laravel/blob/main/README.md Run these commands to install the package and publish all required migrations. The migrations must be published manually; the first Teams::create() call requires the 'options' table. Set TEAMS_KEY_TYPE before migrating if using UUID/ULID keys. ```bash composer require roundly-consulting/teams-for-laravel php artisan vendor:publish --tag="options-migrations" php artisan vendor:publish --tag="contacts-migrations" php artisan vendor:publish --tag="addresses-migrations" php artisan vendor:publish --tag="connections-migrations" php artisan vendor:publish --tag="approvals-migrations" php artisan vendor:publish --tag="teams-migrations" php artisan migrate ``` -------------------------------- ### Create team, add members, and manage invites Source: https://github.com/roundly-consulting/teams-for-laravel/blob/main/README.md Create a team with an owner, add a member with a role, create an invite, accept it, and check permissions and roles. The owner automatically joins as 'owner'. ```php use RoundlyConsulting\Teams\DataTransferObjects\CreateTeamData; use RoundlyConsulting\Teams\Facades\Teams; $team = Teams::create(new CreateTeamData(name: 'Acme', owner: $owner)); // owner joins as 'owner' Teams::for($team)->members()->add($alice, 'editor'); $invite = Teams::for($team)->invites()->create(role: 'member', email: 'jane@acme.test'); Teams::invites()->accept($invite->code, $jane, email: $jane->email); $alice->can('teams.posts.publish', $team); // true $jane->hasTeamRole($team, 'member'); // true $owner->can('teams.owner', $team); // true ``` -------------------------------- ### Register roles and add HasTeams trait to user model Source: https://github.com/roundly-consulting/teams-for-laravel/blob/main/README.md Register roles in a service provider's boot method using Teams::roles()->register(). Add the HasTeams trait to your user model to enable team functionality. ```php use RoundlyConsulting\Teams\Facades\Teams; use RoundlyConsulting\Teams\Traits\HasTeams; Teams::roles()->register('owner', 'Owner', ['*']); Teams::roles()->register('editor', 'Editor', ['posts.edit', 'posts.publish']); Teams::roles()->register('member', 'Member', ['posts.view']); class User extends Authenticatable { use HasTeams; } ```