PHPackages                             nietthijmen/laravel-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. nietthijmen/laravel-roles

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

nietthijmen/laravel-roles
=========================

This is my package laravel-roles

1.0.0(11mo ago)00[5 PRs](https://github.com/NietThijmen/laravel-roles/pulls)MITPHPPHP ^8.4CI passing

Since Jun 13Pushed 1mo agoCompare

[ Source](https://github.com/NietThijmen/laravel-roles)[ Packagist](https://packagist.org/packages/nietthijmen/laravel-roles)[ Docs](https://github.com/nietthijmen/laravel-roles)[ GitHub Sponsors](https://github.com/NietThijmen)[ RSS](/packages/nietthijmen-laravel-roles/feed)WikiDiscussions main Synced 1mo ago

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

Laravel roles
=============

[](#laravel-roles)

This package provides a simple and easy way to manage roles in your laravel package.

Installation
------------

[](#installation)

1. Install the package via composer:

```
composer require nietthijmen/laravel-roles
```

2. Run the install command to publish the configuration file:

```
php artisan roles:install
```

3. Grab a cup of coffee and wait for the package to be installed.
4. Add the `HasRoles` trait to your User model:

```
use Nietthijmen\LaravelRoles\Traits\HasRoles;
class User extends Authenticatable
{
    use HasRoles;

    // ...
}
```

5. Alias your middleware (if you want to use this)

```
// bootstrap/app.php
withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'role' => \NietThijmen\LaravelRoles\Http\Middleware\RoleMiddleware::class
        ]);
})
```

6. Add the RoleServiceProvider

```
// bootstrap/providers.php
