PHPackages                             mr-luke/privileges - 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. [Database &amp; ORM](/categories/database)
4. /
5. mr-luke/privileges

ActiveLibrary[Database &amp; ORM](/categories/database)

mr-luke/privileges
==================

Laravel 5 package that adds roles &amp; priviledges to your application.

v1.0.0-rc.1(5y ago)05.0k1MITPHPPHP &gt;=7.1CI failing

Since Feb 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mr-luke/privileges)[ Packagist](https://packagist.org/packages/mr-luke/privileges)[ RSS](/packages/mr-luke-privileges/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (6)Versions (13)Used By (0)

Privileges Manager - Laravel multi-roles manager Package.
=========================================================

[](#privileges-manager---laravel-multi-roles-manager-package)

[![Latest Stable Version](https://camo.githubusercontent.com/4a9f23619bc71fb39c1e9e4a55349ae1d8c1ef0f325773f41553f1fc00bf1982/68747470733a2f2f706f7365722e707567782e6f72672f6d722d6c756b652f70726976696c656765732f762f737461626c65)](https://packagist.org/packages/mr-luke/privileges)[![License](https://camo.githubusercontent.com/6036b334519561d00f1251ee5c34192596906dcf1df219b6565a49b57147cd27/68747470733a2f2f706f7365722e707567782e6f72672f6d722d6c756b652f70726976696c656765732f6c6963656e7365)](https://packagist.org/packages/mr-luke/privileges)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/aa0e068f810f5efd89c73e1fb062b8e258e007a0036118622dfacb2a9f9e8496/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d722d6c756b652f70726976696c656765732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mr-luke/privileges/?branch=master)[![Build Status](https://camo.githubusercontent.com/0df3fd85e1f3860cc065813c5af0fab8cc7a52745f839906fe1afe023cd867da/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d722d6c756b652f70726976696c656765732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mr-luke/privileges/build-status/master)

This package provides privileges manager that supports multi-roles, permissions and restrictions.

- [Getting Started](#getting-started)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Examples](#examples)
- [Plans](#plans)

Getting Started
---------------

[](#getting-started)

Privileges Manager has been developed using `Laravel 5.5`It's recommended to test it out before using with previous versions. PHP &gt;= 7.1.3 is required.

*Note! This package is still in **Beta** release.*

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

[](#installation)

To install through composer, simply put the following in your composer.json file and run `composer update`

```
{
    "require": {
        "mr-luke/privileges": "~1.0.0"
    }
}
```

Or use the following command

```
composer require "mr-luke/privileges"
```

Next, add the service provider to `app/config/app.php`

```
Mrluke\Privileges\PrivilegesServiceProvider::class,

```

*Note: Package is auto-discoverable!*

Configuration
-------------

[](#configuration)

To use `Privileges` you need to setup your `Authorizable` model &amp; allowed `scopes` in [config file](config/privileges.php):

```
/*
|--------------------------------------------------------------------------
| Authorizable model class
|--------------------------------------------------------------------------
|
| This config specify which model class is authorizable.
|
*/

'authorizable' => \App\User::class,

/*
|--------------------------------------------------------------------------
| Available scopes
|--------------------------------------------------------------------------
|
| This config is a list of all available in application scopes.
|
*/

'scopes'   => [
    'users', 'settings',
],
```

You can also set a mapping rule that transform a given Eloquent model reference to a scope:

```
/*
|--------------------------------------------------------------------------
| Models mapping
|--------------------------------------------------------------------------
|
| This config allows you to map all application models to specific scopes.
|
| Example:      \App\Model::class => 'scope'
|
*/

'mapping'   => [
    \App\Users::class => 'users'
],
```

By default `Detector` returns `bool` value in case of allowed or denied access but you can set a custom on:

```
'allowed_value' => true,
'denied_value'  => false,
```

You can also publish config file via command:

```
php artisan vendor:publish
```

Usage
-----

[](#usage)

### Facade

[](#facade)

You can access to `Manager` and `Detector` using `Mrluke\Privileges\Facades` namespace.

### Contracts

[](#contracts)

`Privileges` is a packages built with Contracts. You need to implement `Mrluke\Privileges\Contracts\Authorizable` to your User model first. It is recommended to use default `Mrluke\Privilges\Extentions\Authorizable` trait combined with Contract:

```
