NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Permissions are plain string keys on roles. The permission registry, Teams::permissions(), lists every known permission — for a role editor or a permission picker — independently of which roles use them. Permissions are code constants, so the registry lives in memory (there is no database driver):

use RoundlyConsulting\Teams\Facades\Teams;

Teams::permissions()->register('posts.publish', 'Publish posts', group: 'Content');
Teams::permissions()->register('billing.manage', 'Manage billing', group: 'Billing');
Teams::permissions()->group('Content', ['posts.edit', 'posts.delete']);

Teams::permissions()->all();                   // array<string, Permission> — registered only
Teams::permissions()->find('posts.publish');   // ?Permission
Teams::permissions()->fromRoles();             // registered + every distinct permission declared on roles

group() tags permissions with a UI group and keeps the names of those already registered. fromRoles() adds every distinct permission declared on your registered roles, so a host that only declared permissions on roles still gets a full catalogue:

// Section a permission picker by group:
$grouped = collect(Teams::permissions()->fromRoles())->groupBy('group');

$permission = Teams::permissions()->find('posts.publish');
$permission->key;     // 'posts.publish'
$permission->name;    // 'Publish posts'
$permission->group;   // 'Content'

Checking permissions

$team->memberHasPermission($user, 'posts.publish');   // bool
$user->hasTeamPermission($team, 'posts.publish');     // bool — HasTeams
$team->memberHasRole($user, 'admin');                 // bool

$role = $team->findMember($user)?->role();
$role?->hasAnyPermission(['posts.edit', 'posts.publish']);

memberHasPermission() resolves the member’s role (per-team aware) and returns false for non-members, expired memberships and unregistered roles. In controllers and views, prefer the Gate — see Authorization.

Listing permissions

php artisan teams:permissions   # Key | Name | Group

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.