PHPackages                             michalisantoniou6/laravel-cerberus - 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. michalisantoniou6/laravel-cerberus

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

michalisantoniou6/laravel-cerberus
==================================

This package provides a flexible way to add Multi-tenant Role-based Permissions to Laravel 5.\*

2.5.6(7y ago)21.5kMITPHPPHP &gt;=5.5.0

Since Feb 7Pushed 6y agoCompare

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

READMEChangelog (10)Dependencies (7)Versions (38)Used By (0)

Laravel Cerberus
================

[](#laravel-cerberus)

Cerberus is a flexible way to add Role-based Permissions to Laravel 5.\*

Contents
--------

[](#contents)

- [Installation](#installation)
- [Configuration](#configuration)
    - [User relation to roles](#user-relation-to-roles)
    - [Models](#models)
        - [Role](#role)
        - [Permission](#permission)
        - [User](#user)
        - [Soft Deleting](#soft-deleting)
- [Usage](#usage)
    - [Concepts](#concepts)
        - [Checking for Roles &amp; Permissions](#checking-for-roles--permissions)
        - [User ability](#user-ability)
    - [Blade templates](#blade-templates)
    - [Middleware](#middleware)
- [Troubleshooting](#troubleshooting)
- [License](#license)
- [Contribution guidelines](#contribution-guidelines)
- [Additional information](#additional-information)

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

[](#installation)

1. Run this command to install Laravel 5 Cerberus:

```
composer require michalisantoniou6/cerberus

```

Alternatively, you can add just the following to your composer.json. Then run `composer update`:

```
"michalisantoniou6/cerberus": "2.*"
```

Require `dev-master` if you wish to always get the most recent stable version.

```
"michalisantoniou6/cerberus": "dev-master"
```

2. Open your `config/app.php` and add the following to the `providers` array. You can skip this if you're on Laravel 5.5, as the package will register itsself.

```
Michalisantoniou6\Cerberus\CerberusServiceProvider::class,
```

3. If you'd like to use the Facade, add the following to the `aliases` array in `config/app.php`:

```
'Cerberus'   => Michalisantoniou6\Cerberus\CerberusFacade::class,
```

4. Run the command below to publish the package config file `config/cerberus.php`. Set the models and keys in your config file.

```
php artisan vendor:publish
```

5. If you want to use [Middleware](#middleware) (requires Laravel 5.1 or later) you also add the following:

```
    'role' => \Michalisantoniou6\Cerberus\Middleware\CerberusRole::class,
    'permission' => \Michalisantoniou6\Cerberus\Middleware\CerberusPermission::class,
    'ability' => \Michalisantoniou6\Cerberus\Middleware\CerberusAbility::class,
```

to `routeMiddleware` array in `app/Http/Kernel.php`.

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

[](#configuration)

Set the property values in the `config/cerberus.php`. These values will be used by cerberus to refer to the correct user/site/role/permission tables and models.

To customize table names and model namespaces, edit the `config/cerberus.php`.

### User relation to roles

[](#user-relation-to-roles)

Now generate the Cerberus migration:

```
php artisan cerberus:migration
```

It will generate the `_cerberus_setup_tables.php` migration. You may add additional fields to the migration. Review the migration, and run it with the artisan migrate command:

```
php artisan migrate
```

### Models

[](#models)

#### Role

[](#role)

Create a Role model inside `app/models/Role.php` using the following example:

```
