2015-12-14 34 views
3

我已经实现了Laravel 5的收银/计费功能,并且我试图使用检查订阅的中间件保护一组路由。Laravel 5收银中间件路由错误

,我发现了以下错误:

Argument 2 passed to App\Http\Middleware\HasSubscription::handle() must be an instance of App\Http\Middleware\Closure, instance of Closure given 

我的继承人中间件

<?php 

namespace App\Http\Middleware; 

class HasSubscription 
{ 
    public function handle($request, Closure $next) 
    { 
     if ($request->user() && ! $request->user()->subscribed()) { 
      // This user is not a paying customer... 
      return redirect('subscription'); 
     } 

     return $next($request); 
    } 
} 

我的继承人保护航线

Route::get('home', '[email protected]')->middleware('subscription'); 

我的继承人申请航线声明

protected $routeMiddleware = [ 
     'auth' => \App\Http\Middleware\Authenticate::class, 
     'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 
     'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 
     'subscription' => \App\Http\Middleware\HasSubscription::class, 
    ]; 

任何想法,为什么我得到的错误在顶部?

回答