entrust
entrust copied to clipboard
Controller Middleware (Permissions)
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.
Bump.. getting the same error since updating to 5.3
Same issue.
Anyone have a solution yet?
Update your user model:
use Zizaco\Entrust\Traits\EntrustUserTrait;
and
use EntrustUserTrait;
This issue is solved, The code above is correct ans the updated user model as well.