带委托的Laravel 5.2 -无法检查权限并呈现403


Laravel 5.2 with Entrust - not able to check Permission and render 403

我是Laravel的新手,我正在开发一个具有用户,角色和权限的应用程序。我用的是Zizaco/Entrust。我几乎完成了所有的步骤,但是我无法显示403的自定义页面。我的代码如下:

Permission : role-list
Role : Manager

'role-list'分配给' manager' '角色,然后将'manager'角色分配给'ABC'用户。

在我的应用程序'内核文件id添加这些中间件:

protected $routeMiddleware = [
        'auth' => 'Eybos'Http'Middleware'Authenticate::class,
        'auth.basic' => 'Illuminate'Auth'Middleware'AuthenticateWithBasicAuth::class,
        'can' => 'Illuminate'Foundation'Http'Middleware'Authorize::class,
        'guest' => 'Eybos'Http'Middleware'RedirectIfAuthenticated::class,
        'throttle' => 'Illuminate'Routing'Middleware'ThrottleRequests::class,
        'role' => 'Zizaco'Entrust'Middleware'EntrustRole::class,
        'permission' => 'Zizaco'Entrust'Middleware'EntrustPermission::class,
        'ability' => 'Zizaco'Entrust'Middleware'EntrustAbility::class,
    ];

在我的路由文件:

Route::get( 'backend/roles', [ 'as' => 'backend.roles.index', 'uses' => 'Backend'RoleController@index', 'middleware' => ['permission:role-list|role-create|role-edit|role-delete']] );
然后创建一个文件:resources/views/errors/403.blade.php
@extends('layouts.backend')
@section('content')
    <h1>You don't have permission.</h1>
@endsection

但是当我尝试访问页面时,我得到这个错误:

FatalErrorException in Decorator.php line 80:
Trying to clone an uncloneable object of class Symfony'Component'HttpKernel'Exception'HttpException

不确定这是否是正确的答案,但是…

打开Lewis->presenter->src->Decorator.php

在第80行你应该看到"$object = clone $object;"

注释掉这行,它应该开始使用权限。