中间件参数中的laravel中间件错误

时间:2016-12-29 20:32:21

标签: laravel laravel-middleware

我的laravel 5中间件代码r中有错误 的中间件     

use Closure;

 class RoleMiddleware {

/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
 */
public function handle($request, Closure $next,$rr)
{
     echo "Role: ".$rr;

    return $next($request);
}

}

karnel

 <?php namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel {

    /**
     * The application's global HTTP middleware stack.
     *
     * @var array
     */
    protected $middleware = [
        'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
        'Illuminate\Cookie\Middleware\EncryptCookies',
        'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
        'Illuminate\Session\Middleware\StartSession',
        'Illuminate\View\Middleware\ShareErrorsFromSession',
        'App\Http\Middleware\VerifyCsrfToken',
    ];

    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => 'App\Http\Middleware\Authenticate',
        'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
        'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
        'Role' => '\App\Http\Middleware\RoleMiddleware',
    ];

}

测试控制器

    <?php
 //use View;
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
//namespace a;

 class TestController extends Controller
 {
 public function index()
 {
         echo "<br>Test Controller.";
 }


 }
 ?>

路由器

  Route::get('role',[
   'middleware' => 'Role:editor',
   'uses' => 'TestController@index',
]);

;

它显示错误&#34;在translate.php第1029行中的ReflectionException:类角色:编辑器不存在&#34;

请帮忙。

0 个答案:

没有答案