---
title: "Assigning roles — Permissions for Laravel | Roundly"
description: "Assign, remove and sync roles on any holder; permissions granted to a role flow to every model that holds it."
url: https://roundly-consulting.com/open-source/docs/permissions-for-laravel/assigning-roles
language: en
---

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

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

# Assigning roles

Assign through Permissions::for($holder). assignRole is additive and variadic, removeRole detaches, and syncRoles makes the given set the exact role set:

```php
use RoundlyConsulting\Permissions\Facades\Permissions;

Permissions::for($user)->assignRole('administrator');
Permissions::for($user)->assignRole('editor', 'reviewer');   // variadic, additive
Permissions::for($user)->assignRole(['editor', $role]);      // arrays, Role models, backed enums

Permissions::for($user)->removeRole('administrator');
Permissions::for($user)->syncRoles(['editor']);              // exact role set
Permissions::for($user)->forgetAllAuthorization();           // every role and direct grant
```

Names, backed enums, Role models, arrays and nested iterables are all accepted. An unknown role name throws RoleDoesNotExist; an unsaved Role model throws PermissionException. syncRoles runs in a transaction, so a concurrent check never sees an empty mid-sync role set.

Role writes need a holder with HasRoles — Permissions::for($role)->assignRole() throws a PermissionException, because a Role holds permissions, never roles. On the model, the HasRoles verbs are shorthand for the same calls:

```php
$user->assignRole('administrator');
$user->removeRole('administrator');
$user->syncRoles(['editor']);
$user->forgetAllAuthorization();
```

## Inheriting permissions through roles

Grant permissions to a role once and every holder inherits them. Change the role and every holder updates — no per-user writes:

```php
use RoundlyConsulting\Permissions\Facades\Permissions;

Permissions::permission('articles.publish');
Permissions::for(Permissions::role('editor'))->givePermissionTo('articles.publish');

Permissions::for($user)->assignRole('editor');
$user->hasPermissionTo('articles.publish'); // true — inherited via the role
```

## Removing everything

Permissions::for($holder)->forgetAllAuthorization() detaches every role and every direct permission in one transaction. Use it when a holder is deleted — see Deleting holders.

## 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/permissions-for-laravel.md)
