Looking to hire Laravel developers? Try LaraJobs

teams-for-laravel maintained by roundly-consulting

Description
Associate users with teams, roles, permissions, and invitations in Laravel.
Last update
2026/10/03 20:42 (dev-main)
License
Downloads
2

Comments
comments powered by Disqus

Teams for Laravel

Teams, roles, permissions and invitations for any Eloquent model. Members carry a role, roles carry permissions checked through Laravel's Gate, and teams issue expiring, email-targeted invites and handle join requests.

Installation

Requires PHP 8.4 and Laravel 12 or 13.

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

Publish every tag: none of these packages auto-load their migrations, and the very first Teams::create() needs the options table. If your users have UUID/ULID keys, set TEAMS_KEY_TYPE before migrating.

Usage

Register your roles in a service provider's boot method and add HasTeams to your user:

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;
}

Then create a team, seat members and invite people:

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

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/teams-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

License

The MIT License (MIT). Please see License File for more information.