PHPackages                             actengage/roles - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. actengage/roles

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

actengage/roles
===============

A simple role management package for Laravel.

v2.0.0(4y ago)0200[2 PRs](https://github.com/actengage/roles/pulls)MITPHPPHP ^8.0

Since Jan 14Pushed 3y agoCompare

[ Source](https://github.com/actengage/roles)[ Packagist](https://packagist.org/packages/actengage/roles)[ RSS](/packages/actengage-roles/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (5)Versions (17)Used By (0)

Roles
=====

[](#roles)

A simple package for assigning many-to-many "roles" to Eloquent models. This packages provides the migrations, a config file, a Role model, a Roleable trait, and an ability to sync the roles from a config to the database.

### Installation

[](#installation)

```
composer require actengage/roles

```

### Implementation

[](#implementation)

To implement Roles, you just need to assign the `Roleable` trait to the model receiving the roles.

```
namespace App\User;

use Actenage\Roles\Roleable;
use Illuminate\Database\Eloquent\Model;

class User extends Model {

    use Roleable;

}

```

### Gates &amp; Policies

[](#gates--policies)

Roles are meant to be used directly within Laravel Gates and Policies.

```
Gate::define('sudo', function ($user, $model) {
    return $user->hasRole(Role::findByName('account_owner'));
});

```

```
