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

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

mistery23/laravel-roles
=======================

Powerful package for handling roles, permissions, and levels in Laravel.

v3.2.1(6y ago)0159MITPHPPHP &gt;=7.3

Since Feb 22Pushed 6y agoCompare

[ Source](https://github.com/mistery23/laravel-roles)[ Packagist](https://packagist.org/packages/mistery23/laravel-roles)[ RSS](/packages/mistery23-laravel-roles/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (12)Versions (31)Used By (0)

Laravel Roles
=============

[](#laravel-roles)

#### Table of contents

[](#table-of-contents)

- [About](#about)
- [Features](#features)
- [Installation](#installation)
    - [Composer](#composer)
    - [Service Provider](#service-provider)
    - [Publish All Assets](#publish-all-assets)
    - [Publish Specific Assets](#publish-specific-assets)
    - [HasRoleAndPermission Trait And Contract](#hasroleandpermission-trait-and-contract)
    - [Migrations and Seeds](#migrations-and-seeds)
- [Usage](#usage)
    - [Creating Roles](#creating-roles)
    - [Attaching, Detaching Roles and Permissions](#attaching-detaching-role-and-permissions)
    - [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)
- [Configuration](#configuration)
    - [Environment File](#environment-file)
- [Optional API Routes](#optional-api-routes)
- [Tests](#tests)
- [File Tree](#file-tree)
- [License](#license)

About
-----

[](#about)

A Powerful package for handling roles and permissions in Laravel. Supports Laravel 5.8, and 6.0.

Features
--------

[](#features)

Laravel Roles FeaturesBuilt in migrations with ability to publish and modify your own.Built in command with ability to modify your own seed data from config.Roles with levels and relationships to users, permissionsPermissions with relationships to users and levelsExtended role and permissionSoft deletes with full restore and destroyOptional Api methods for manage Roles and PermissionsLots of [configuration](#configuration) optionsLots of [configuration](#configuration-seed-data) seedAll Extendable from [.env](#environment-file)Installation
------------

[](#installation)

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

### Composer

[](#composer)

From your projects root folder in terminal run:

Laravel 5.8 and up use:

```
    composer require mistery23/laravel-roles

```

### Service Provider

[](#service-provider)

- Laravel 5.8 and up Uses package auto discovery feature, no need to edit the `config/app.php` file.

```
'providers' => [

    ...

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

],
```

### Publish All Assets

[](#publish-all-assets)

```
    php artisan vendor:publish --tag=laravelroles
```

### Publish Specific Assets

[](#publish-specific-assets)

```
    php artisan vendor:publish --tag=laravelroles-config
    php artisan vendor:publish --tag=laravelroles-migrations
```

### 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 Mistery23\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:

```
