任何人都可以想到一种灵活的中间件方式或者如果'如果'声明,以便我们可以更安全地使用路由模型绑定?
Route::get('/channel-groups/{channelGroup}/channels/{channel}', [
'as' => 'channel-groups',
'uses' => function(\App\Distribution\UserConfigurations\ChannelGroup $channelGroup, \App\Distribution\UserConfigurations\Channel $channel){
//@todo: middleware
if(!$channelGroup->Channels->contains($channel)){
return abort(401, 'Unauthorized');
}
return $channel;
}
]);