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

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

lmslfm/entrust
==============

This package provides a flexible way to add role-based permissions to Laravel and is a fork from trebol/entrust from Zizaco/entrust

8.0.1(3y ago)1193MITPHPPHP ^7.3 | ^8.0.2

Since Aug 28Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

ENTRUST (Laravel Package)
=========================

[](#entrust-laravel-package)

[![Build Status](https://camo.githubusercontent.com/c6bca75d6175ac95e522b23a41ebc79b0696071852df5fc8117302b6101e479a/68747470733a2f2f7472617669732d63692e6f72672f6a726f6d65726f39382f656e74727573742e737667)](https://travis-ci.org/jromero98/entrust)[![Latest Stable Version](https://camo.githubusercontent.com/84f737f669ef530ef6c7ce9cae40343337959a09e2f92415ae5d3673a7b5be1f/68747470733a2f2f706f7365722e707567782e6f72672f6c6d736c666d2f656e74727573742f762f737461626c653f666f726d61743d706c6173746963)](https://packagist.org/packages/lmslfm/entrust)[![Total Downloads](https://camo.githubusercontent.com/b1e8737d3a659bc4e6fb040ffdcdd295ed383f626ff92cd81fe2f7eee02a74a5/68747470733a2f2f706f7365722e707567782e6f72672f6c6d736c666d2f656e74727573742f646f776e6c6f6164733f666f726d61743d706c6173746963)](https://packagist.org/packages/lmslfm/entrust)[![License](https://camo.githubusercontent.com/929bb5c395891b113ebe866d14c852e5d57d0121a671fa3d057c90c6c9f1135b/68747470733a2f2f706f7365722e707567782e6f72672f6c6d736c666d2f656e74727573742f6c6963656e73653f666f726d61743d706c6173746963)](https://packagist.org/packages/lmslfm/entrust)

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

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, just run:

We do not support laravel 8 now, It is just for Laravel 7, run this :

```
composer require lmslfm/entrust
```

2). In the same `config/app.php` and add the following to the `aliases ` array:

```
'Entrust'   => Lmslfm\Entrust\EntrustFacade::class,
```

3). Run the command below to publish the package config file `config/entrust.php`:

```
php artisan vendor:publish
```

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

```
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => Namespace\Of\Your\User\Model\User::class, // Default: App\User::class
        'table' => 'users',
    ],
],
```

5). If you want to use [Middleware](#middleware) you also need to add the following:

```
    'role' => \Lmslfm\Entrust\Middleware\EntrustRole::class,
    'permission' => \Lmslfm\Entrust\Middleware\EntrustPermission::class,
    'ability' => \Lmslfm\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)

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:

- `roles` — stores role records
- `permissions` — stores permission records
- `role_user` — stores [many-to-many](http://laravel.com/docs/4.2/eloquent#many-to-many) relations between roles and users
- `permission_role` — 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 Role model inside `app/models/Role.php` using the following example:

```
