entrust icon indicating copy to clipboard operation
entrust copied to clipboard

Controller Middleware (Permissions)

Open psaunders opened this issue 9 years ago • 5 comments

This controller constructor code works, no problem and handy for a Laravel Resource Constructor

public function __construct(){
        $this->middleware('role:administrator|writer', ['except' => ['index','show']]);
}

This gives you an error

public function __construct(){
        $this->middleware('permission:create-article', ['only' => ['create','store']]);
}

ErrorException in Gate.php line 321: Illegal offset type in isset or empty. The $ability var is an array when passed from the controller, but a string when passed from routes.php.

psaunders avatar Nov 20 '15 18:11 psaunders

Bump.. getting the same error since updating to 5.3

mylesthedev avatar Sep 22 '16 23:09 mylesthedev

Same issue.

finalblast avatar Oct 25 '16 13:10 finalblast

Anyone have a solution yet?

swaylay avatar Dec 13 '16 18:12 swaylay

Update your user model:

use Zizaco\Entrust\Traits\EntrustUserTrait;

and

use EntrustUserTrait;

freel132 avatar Jan 15 '17 15:01 freel132

This issue is solved, The code above is correct ans the updated user model as well.

BrunoNicholas avatar Oct 14 '19 17:10 BrunoNicholas