【发布时间】:2018-03-09 11:04:41
【问题描述】:
我正在尝试在特定路由以及控制器构造函数内部运行中间件。
但是,在控制器构造函数中定义的中间件似乎没有为包含中间件的路由执行。
这不可能吗? (所有这些中间件都在 kernel.php 中注册,所有中间件在构造函数中都在添加中间件到路由之前工作)
路线
Route::get('/{organization_slug}', function($organization_slug){
$organization = \App\Organization::where('slug', '=', $organization_slug)->first();
$app = app();
$controller = $app->make('\App\Http\Controllers\OrganizationController');
return $controller->callAction('details', $parameters = array($organization->id));
})->middleware('verifyorganizationslug');
控制器构造函数
public function __construct()
{
$this->middleware('auth', ['only' => ['create', 'update', 'store']]);
$this->middleware('accountactive', ['only' => ['create', 'update', 'store']]);
$this->middleware('ownsorganization', ['only' => ['update']]);
$this->middleware('verifyorganization', ['only' => ['details']]);
}
【问题讨论】: