PHPackages                             ssswang/entrust - 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. ssswang/entrust

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

ssswang/entrust
===============

This package provides a flexible way to add Role-based Permissions to Laravel/Lumen 6

v3.1.5(2w ago)02MITPHPPHP &gt;=7.2

Since Jul 22Pushed 2w agoCompare

[ Source](https://github.com/ssswang/entrust)[ Packagist](https://packagist.org/packages/ssswang/entrust)[ RSS](/packages/ssswang-entrust/feed)WikiDiscussions master Synced 1w ago

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

ENTRUST for eTools (Laravel Package)
====================================

[](#entrust-for-etools-laravel-package)

Entrust is a succinct and flexible way to add Role-based Permissions to **Laravel 8**.

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)
    - [Short syntax route filter](#short-syntax-route-filter)
    - [Route filter](#route-filter)
- [Troubleshooting](#troubleshooting)
- [License](#license)
- [Contribution guidelines](#contribution-guidelines)
- [Additional information](#additional-information)

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

[](#installation)

1. In order to install Laravel Entrust for mimr, just add the following to your composer.json. Then run `composer update`:

```
"ssswang/entrust": "^3.1"
```

4. Run the command below to publish the package config files config/entrust.php

```
php artisan vendor:publish
```

5. Open your `config/auth.php` and add the following to it:

```
'providers' => [
    'user' => [
        'driver' => 'shibboleth',
        'model' => 'App\YourModel',
        'table' => 'YourModelTable',
        'primaryKey' => 'm_staff_id',
    ],
],
```

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

```
    'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
    'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
    'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
```

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

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

[](#configuration)

Set the property values in the `config/auth.php`. These values will be used by entrust to refer to the correct user table and model.

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

### User relation to roles

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

For your local dev env setup, YOU SHOULD HAVE MIMR2 ON YOUR LOCAL, IF YOU DO NOT, you may need following mockup tables

Now generate the Entrust migration:

```
php artisan entrust:migration
```

It will generate the `_entrust_setup_tables.php` migration. You may now run it with the artisan migrate command:

```
php artisan migrate
```

After the migration, four new tables will be present:

- `m_access_group` — stores role records
- `m_permission` — stores permission records
- `m_staff_access` — stores [many-to-many](http://laravel.com/docs/4.2/eloquent#many-to-many) relations between roles and users
- `m_access_group_permission` — stores [many-to-many](http://laravel.com/docs/4.2/eloquent#many-to-many) relations between roles and permissions

### Models

[](#models)

#### Role

[](#role)

Create a AccessGroup model inside `app/MIMRModel/AccessGroup.php` using the following example:

```
