Skip to content
プロジェクト

概要

Laravel package for managing teams and user permissions.

Web・アプリ開発

この数値の測り方

できること

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

計測したスター増加

24時間
0
7日間
-1
15日間
-1
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

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.

関連プロジェクトを探す

読み込み中…