Skip to content
Proyectos

Acerca de

Laravel package for managing teams and user permissions.

Desarrollo web y de aplicaciones

Cómo se miden estas cifras

What you can do

  • 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.

Crecimiento de estrellas medido

in 24h
0
in 7 days
-1
in 15 days
-1
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

Jurager/Teams

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.
  • Limit API tokens to a list of permissions, with Sanctum, Passport, or any provider.
  • 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.

Explorar proyectos relacionados

Cargando…