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

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

ffogarasi/laravel-roles
=======================

Powerful package for handling roles and permissions in Laravel 5.4+

v1.0.2(9y ago)011MITPHPPHP &gt;=5.6.4

Since Feb 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ffogarasi/laravel-roles)[ Packagist](https://packagist.org/packages/ffogarasi/laravel-roles)[ RSS](/packages/ffogarasi-laravel-roles/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Roles And Permissions For Laravel 5.4
=====================================

[](#roles-and-permissions-for-laravel-54)

[![Total Downloads](https://camo.githubusercontent.com/1525da26bf2c51d0f0d6a566d7fa9914cf6a2c8f8e7e4a551faa0493c754fd59/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f6c61726176656c2d726f6c65732f642f746f74616c2e737667)](https://packagist.org/packages/jeremykenedy/laravel-roles)[![Latest Stable Version](https://camo.githubusercontent.com/94a8add8ed761e00b7cebc8e2508b4c727ee86bf35ac20f83c0f2d33b446a967/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f6c61726176656c2d726f6c65732f762f737461626c652e737667)](https://packagist.org/packages/jeremykenedy/laravel-roles)[![License](https://camo.githubusercontent.com/98b7d9d31feac8d1f87ed1b254eedfa01e808770f5d8c015ee0daed67fc92395/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f6c61726176656c2d726f6c65732f6c6963656e73652e737667)](https://packagist.org/packages/jeremykenedy/laravel-roles)

A Powerful package for handling roles and permissions in Laravel 5.4.

- [Installation](#installation)
    - [Composer](#composer)
    - [Service Provider](#service-provider)
    - [Config File And Migrations](#config-file-and-migrations)
    - [HasRoleAndPermission Trait And Contract](#hasroleandpermission-trait-and-contract)
    - [Migrations and Seeds](#migrations-and-seeds)
    - [Migrate from Bican roles](#Migrate-from-bican-roles)
- [Usage](#usage)
    - [Creating Roles](#creating-roles)
    - [Attaching, Detaching and Syncing Roles](#attaching-detaching-and-syncing-roles)
    - [Assign a user role to new registered users](#assign-a-user-role-to-new-registered-users)
    - [Checking For Roles](#checking-for-roles)
    - [Levels](#levels)
    - [Creating Permissions](#creating-permissions)
    - [Attaching, Detaching and Syncing Permissions](#attaching-detaching-and-syncing-permissions)
    - [Checking For Permissions](#checking-for-permissions)
    - [Permissions Inheriting](#permissions-inheriting)
    - [Entity Check](#entity-check)
    - [Blade Extensions](#blade-extensions)
    - [Middleware](#middleware)
- [Config File](#config-file)
- [More Information](#more-information)
- [License](#license)

---

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

[](#installation)

This package is very easy to set up. There are only couple of steps.

### Composer

[](#composer)

Pull this package in through Composer

```
composer require jeremykenedy/laravel-roles

```

### Service Provider

[](#service-provider)

Add the package to your application service providers in `config/app.php` file.

```
'providers' => [

    ...

    /**
     * Third Party Service Providers...
     */
    jeremykenedy\LaravelRoles\RolesServiceProvider::class,

],
```

### Config File

[](#config-file)

Publish the package config file and migrations to your application. Run these commands inside your terminal.

```
php artisan vendor:publish --provider="jeremykenedy\LaravelRoles\RolesServiceProvider" --tag=config
php artisan vendor:publish --provider="jeremykenedy\LaravelRoles\RolesServiceProvider" --tag=migrations
php artisan vendor:publish --provider="jeremykenedy\LaravelRoles\RolesServiceProvider" --tag=seeds

```

### HasRoleAndPermission Trait And Contract

[](#hasroleandpermission-trait-and-contract)

1. Include `HasRoleAndPermission` trait and also implement `HasRoleAndPermission` contract inside your `User` model. See example below.
2. Include `use jeremykenedy\LaravelRoles\Traits\HasRoleAndPermission;` in the top of your `User` model below the namespace and implement the `HasRoleAndPermission` trait. See example below.

Example `User` model Trait And Contract:

```
