Some Tips when using Entrust in Laravel

I got the problem when using bican/roles Role module in my Laravel project.

There is an error when I check permission.

So I decided to move zizaco/entrust and tested all features working normal.

How to install Entrust

Install use composer

Setting to config/app.php

Add bellow line to providers array in config/app.php.

Add bellow line to aliases array in config/app.php.

Setting to app/Http/Kernal.php

Add bellow lines to routeMiddleware array in app/Http/Kernal.php.

Publish entrust.php file

Database Setup

Generate Entrust migration

It will generate the <timestamp>_entrust_setup_tables.php migration.

Execute migration

Trouble shootings

Error when execute migration

After create <timestamp>_entrust_setup_tables.php, you have to write your users table in this file. Open <timestamp>_entrust_setup_tables.php file and write name of users table to 28 line.

This cache store does not support tagging

Set CACHE_DRIVER=array in .env file.

Error when delete role

In Laravel 5.2, error is occured when delete role. Because Entrust get User class using Config::get('auth.model').

EntrustRoleTrait.php file

So We have to return right user model by that position. There are two solutions for this.

1. Change EntrustRoleTrait.php file to use correct configuration value.

We can change Config::get('auth.model') to Config::get('auth.providers.users.model'). Laravel 5.2 already have users model information in that position.

2. Add auth.model value to config/auth.php file

We can also add new value to config/auth.php file to allow Entrust get rights value.



You may also like...

Leave a Reply