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

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

arvindkumarbadwal/entrust-mongodb
=================================

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

02271PHP

Since Nov 14Pushed 7y agoCompare

[ Source](https://github.com/arvindkumarbadwal/entrust-mongodb)[ Packagist](https://packagist.org/packages/arvindkumarbadwal/entrust-mongodb)[ RSS](/packages/arvindkumarbadwal-entrust-mongodb/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

ENTRUST FOR MONGODB (Moloquent) (Laravel 5 Package)
===================================================

[](#entrust-for-mongodb-moloquent-laravel-5-package)

Contents
--------

[](#contents)

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
    - [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)

Prerequisites
-------------

[](#prerequisites)

Make sure you have the MongoDB PHP driver installed. You can find installation instructions at

Install Mongodb Package For Laravel :

[jenssegers/mongodb](https://github.com/jenssegers/laravel-mongodb)

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

[](#installation)

1. In order to install, Run the command below:

```
composer require "arvindkumarbadwal/entrust-mongodb"
```

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

```
Arvindkumar\EntrustMongoDB\EntrustServiceProvider::class,
```

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

```
'EntrustMongoDB'   => Arvindkumar\EntrustMongoDB\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' => \Arvindkumar\EntrustMongoDB\Middleware\EntrustRole::class,
    'permission' => \Arvindkumar\EntrustMongoDB\Middleware\EntrustPermission::class,
    'ability' => \Arvindkumar\EntrustMongoDB\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`.

### Models

[](#models)

#### Role

[](#role)

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

```
