PHPackages                             kawsarjoy/rolepermission - 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. kawsarjoy/rolepermission

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

kawsarjoy/rolepermission
========================

A role permission package for laravel

v1.0.7(5mo ago)77021MITPHP

Since Oct 28Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/kawsarjoy/rolepermission)[ Packagist](https://packagist.org/packages/kawsarjoy/rolepermission)[ RSS](/packages/kawsarjoy-rolepermission/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (10)Used By (0)

Roles And Permissions For Laravel 5.7 or Higher
===============================================

[](#roles-and-permissions-for-laravel-57-or-higher)

A Simple package for handling roles and permissions in Laravel.

- [Installation](#installation)
    - [Composer](#composer)
    - [Service Provider](#service-provider)
    - [Config File](#config-file)
    - [Permissible Trait](#permissible-trait)
    - [Migrations and Seeds](#migrations-and-seeds)
- [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)
    - [Creating Permissions](#creating-permissions)
    - [Attaching, Detaching and Syncing Permissions](#attaching-detaching-and-syncing-permissions)
    - [Checking For Permissions](#checking-for-permissions)
    - [Blade Extensions](#blade-extensions)
    - [Gate](#gate)
    - [Middleware](#middleware)
- [Config File](#config-file)
- [More Information](#more-information)
- [Opening an Issue](#opening-an-issue)
- [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 kawsarjoy/rolepermission

```

### Service Provider

[](#service-provider)

- Laravel 5.5 and up Uses package auto discovery feature, no need to edit the `config/app.php` file.
- Laravel 5.4 and below Add the package to your application service providers in `config/app.php` file.

```
'providers' => [

    ...

    /**
     * Third Party Service Providers...
     */
    KawsarJoy\RolePermission\RolePermissionServiceProvider::class,

],
```

### Config File

[](#config-file)

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

```
php artisan vendor:publish --provider="KawsarJoy\RolePermission\RolePermissionServiceProvider" --tag="config"
you may set `rolepermission-enable` to `false` to disable the feature.
you may set `do-migration` to `false` in config file to disable the migration.
Note: database must have all the necessary tables and columns if you disable migration.

```

### Migration File

[](#migration-file)

Publish the package migration file to your application. Run these commands inside your terminal.

```
php artisan vendor:publish --provider="KawsarJoy\RolePermission\RolePermissionServiceProvider" --tag="migration"

```

### Migration File With Updated Timestamp

[](#migration-file-with-updated-timestamp)

Publish the package migration file to your application with updated timestamp. Run these commands inside your terminal.

```
php artisan vendor:publish --provider="KawsarJoy\RolePermission\RolePermissionServiceProvider" --tag="migration-latest"

```

### Permissible Trait

[](#permissible-trait)

1. Include `Permissible` trait and also implement `Permissible` contract inside your `User` model. See example below.
2. Include `use KawsarJoy\RolePermission\Permissible;` in the top of your `User` model below the namespace and implement the `Permissible` trait. See example below.

Example `User` model Trait And Contract:

```
