---
title: "Per-team role overrides — Teams for Laravel | Roundly"
description: "Let each team redefine a role’s permissions on top of the global roles — tenant-scoped, off by default, zero queries when disabled."
url: https://roundly-consulting.com/open-source/docs/teams-for-laravel/per-team-roles
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Teams for Laravel](https://roundly-consulting.com/open-source/docs/teams-for-laravel.md)

# Per-team role overrides

Enable roles.per\_team to let each team diverge from the global roles, so one tenant’s Editor can do more than another’s. An override for a (team, key) pair wins over the global definition; every other key falls back to the global role. With the flag off, resolution goes straight to the global provider with no extra queries:

```php
// .env → TEAMS_PER_TEAM_ROLES=true
Teams::roles()->register('editor', 'Editor', ['posts.edit']);   // global baseline

Teams::for($team)->roles()->define(
    'editor',
    'Senior Editor',
    ['posts.edit', 'posts.publish'],
    'Editor with publishing rights for this workspace',
);
// or: $team->defineRole('editor', 'Senior Editor', ['posts.edit', 'posts.publish']);

$user->can('teams.posts.publish', $team);     // true for THIS team only
Teams::for($team)->roles()->all();            // effective map — global roles merged with overrides
Teams::for($team)->roles()->find('editor');   // ?Role — the override when one exists
```

roles()->define() upserts a team\_role\_overrides row on (team\_id, key) — call it again to change the override; a soft-deleted override is restored and redefined. Permissions may be strings or Permission objects; only their keys are stored.

## Resolving roles for a team

```php
use RoundlyConsulting\Teams\Roles\TeamRoleResolver;

$resolver = app(TeamRoleResolver::class);

$resolver->resolve($team, 'editor');   // ?Role — the team's override if any, else the global role
$resolver->all($team);                 // array<string, Role>

$team->teamRoles()->where('key', 'editor')->first()?->toRole();   // one override as a Role
```

Member::role() goes through the resolver only while per\_team is on — overrides are ignored when it’s off, even if rows exist. TeamRoleResolver is a container singleton you can rebind.

## 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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

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

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/teams-for-laravel.md)
