Skip to content
프로젝트

소개

Laravel package for managing teams and user permissions.

웹 및 앱 개발

이 수치를 측정하는 방법

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.

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

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.

관련 프로젝트 살펴보기

불러오는 중…