我正在尝试在Laravel中创建一条使用正则表达式验证的路由,但是我想指定如果路由失败应如何处理。目前我有:
Route::group(array('prefix' => 'blog'), function() use($site) {
Route::get('{filterType}/{filterTerm}', [ 'uses' => 'BlogController@index' ] )->where('filterType', 'author|topic');
});
但我想要这样的东西(完全编造):
Route::group(array('prefix' => 'blog'), function() use($site) {
Route::get('{filterType}/{filterTerm}', [ 'uses' => 'BlogController@index' ] )->where('filterType', 'author|topic')->else(function(){
// do something else
});
});
从本质上讲,我想处理特定于博客区域的此博客路由的验证,与网站的其余部分不同。也许还有其他事情可以做到这一点,任何指针都会很棒。
谢谢
使用另一个具有相反正则表达式的路由
Route::group(array('prefix' => 'blog'), function(){
Route::get('{filterType}/{filterTerm}', [ 'uses' =>'BlogController@blabla' ])->where('filterType', '^(?!.*(author/|topic/)).*$');
});