Search by

jurager / teams

Jurager

Laravel package to manage team functionality and operate with user permissions.

Package info

github.com/Jurager/teams

pkg:composer/jurager/teams

Fund package maintenance!

Ko Fi

Statistics

Installs: 29 287

Dependents: 0

Suggesters: 0

Stars: 236

Open Issues: 1

4.2.1 2026-10-28 05:21 UTC

README

Latest Stable Version Total Downloads License Ko-fi

A Laravel package for managing teams and user permissions, supporting multi-tenant dynamic roles, role groups, and team-specific permissions.

Users can be organized into groups within teams, each with custom permissions and abilities. Group permissions add to the permissions of the member's role. For a specific record, the user's own rules are checked first, then their groups' rules, then their role's.

Additionally, users can be added to a global group to grant them access across all teams with the group's permissions. This feature is ideal for scenarios like providing support across multiple teams without the need to add users to each team individually.

Features

  • Team-scoped roles and permissions with a fluent API.
  • Works with Laravel's Gate: $user->can(), @can, and the can middleware.
  • Inspect access decisions with Laravel's authorization responses.
  • String-backed enums for role, group, and permission codes.
  • Hierarchical wildcard permissions (articles.*).
  • Team groups that extend role permissions.
  • Record-level allow and forbid rules for members, roles, and groups.
  • Expiring record rules, checked at authorization time.
  • Query users by team-wide permission.
  • Query record rules with their permissions and recipients.
  • Global groups for cross-team access.
  • Ownership transfer.
  • Email invitations.
  • Fast permission checks on lists of records.
  • Team, membership, and access change events.
  • Model factories for your tests.

Requirements

  • PHP 8.3+
  • Laravel 10.30+, 11, 12, or 13

Installation

composer require jurager/teams
php artisan vendor:publish --tag=teams-migrations
php artisan migrate

Add Jurager\Teams\Traits\HasTeams to your User model:

use Jurager\Teams\Traits\HasTeams;

class User extends Authenticatable
{
    use HasTeams;
}

Usage

$team = $owner->teams()->create(['name' => 'Acme']);

$team->roles()->create(['code' => 'member'])->grant('articles.view');
$team->groups()->create(['code' => 'editors'])->grant('articles.*');

$team->add($user)->as('member');
$team->group('editors')->add($user);

$team->member($user)->forbid('articles.delete')->on($article);

$user->can('articles.edit', $article);   // true
$user->can('articles.delete', $article); // false

See the documentation for groups, route protection, invitations, and configuration.

Upgrading

Upgrading from 3.x? See the upgrade guide.

Development

composer install
composer test
composer format:test

License

This package is open-sourced software licensed under the MIT license.