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,
];
任何想法,爲什麼我得到的錯誤在頂部?