PHPackages                             safaeean/zizaco-entrust-laravel-7.0 - 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. safaeean/zizaco-entrust-laravel-7.0

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

safaeean/zizaco-entrust-laravel-7.0
===================================

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

11.0.1(11mo ago)21.5kMITPHPPHP \*

Since Feb 7Pushed 11mo agoCompare

[ Source](https://github.com/safaeean/entrust)[ Packagist](https://packagist.org/packages/safaeean/zizaco-entrust-laravel-7.0)[ RSS](/packages/safaeean-zizaco-entrust-laravel-70/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (39)Used By (0)

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

[](#entrust-laravel-7-package)

> Updated by Safaeean to be compatible with Laravel 7,8,9,10,11

[![Build Status](https://camo.githubusercontent.com/37be7fd6ca6cedac2551a510813404501225f0089b242f883c4dce72d6ce0248/68747470733a2f2f6170692e7472617669732d63692e6f72672f736166616565616e2f656e74727573742e737667)](https://travis-ci.org/safaeean/entrust)[![Version](https://camo.githubusercontent.com/be02540844b9d4fa8af72d96ac3722bbfecef99b4000ac51c758b15ac97b4e61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736166616565616e2f7a697a61636f2d656e74727573742d6c61726176656c2d372e302e737667)](https://packagist.org/packages/safaeean/zizaco-entrust-laravel-7.0)[![License](https://camo.githubusercontent.com/ee8d08ea8f2b232e1a536d27438bfbac35d8e2428d86af64149bac065abda4ac/68747470733a2f2f706f7365722e707567782e6f72672f736166616565616e2f7a697a61636f2d656e74727573742d6c61726176656c2d372e302f6c6963656e73652e737667)](https://packagist.org/packages/safaeean/zizaco-entrust-laravel-7.0)[![Total Downloads](https://camo.githubusercontent.com/2760243bbef0923146489ca0036df636fb95de022a0e21b36e4543b8e7e00ea6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736166616565616e2f7a697a61636f2d656e74727573742d6c61726176656c2d372e302e737667)](https://packagist.org/packages/safaeean/zizaco-entrust-laravel-7.0)

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

If you are looking for the Laravel 4 version, take a look [Branch 1.0](https://github.com/Zizaco/entrust/tree/1.0). It contains the latest entrust version for Laravel 4.

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 7 Entrust, just add the following to your composer.json. Then run `composer update`:

```
"safaeean/zizaco-entrust-laravel-7.0": "1.9.5"
```

Or run this command

```
composer require safaeean/zizaco-entrust-laravel-7.0
```

2. Open your `config/app.php` and add the following to the `providers` array:

```
Zizaco\Entrust\EntrustServiceProvider::class,
```

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

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

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

```
php artisan vendor:publish
```

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

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

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)

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:

```
