有三个过滤器(位置,类别,事件类型)的提供者列表,我需要在路由中连接过滤器以使url更友好,这就像ej .: mysite.com/filter/location/cordoba /事件类型/除草/类别/旅行 这些过滤器不是必需的,所以我可以只过滤位置,或位置和类别,事件类型和类别等。现在我的问题是,我可以做laravel 5.2吗?连接路线,我可以在laravel 5.2中做到这一点吗?
我之前做到这一点是这样的:
Route::get('/filtro/localidad/{localidad?}', [
'uses' => '[email protected]',
'as' => 'site_filter_location_path'
]);
Route::get('/filtro/tipo_evento/{event_type?}', [
'uses' => '[email protected]',
'as' => 'site_filter_event_type_path'
]);
Route::get('/filtro/rubro/{caption?}', [
'uses' => '[email protected]',
'as' => 'site_filter_caption_path'
]);
我需要的是这样的(它送我,我把只有一个或两个参数的误差)
Route::get('/filtro/location/{localidad?}/event_type/{event_type?}/caption/{caption?}', [
'uses' => '[email protected]',
'as' => 'site_filter_path'
]);
比方说,我搜索通过位置和类别,然后该网址将是这样的:mysite.com/location/cordoba/event_type//caption/travel这会产生一个错误的网址,这给了我错误,那么我该怎么做呢?
除了这幸福您可能需要考虑的是,虽然在理论上(根据RFC)在URL中使用双斜杠是可以接受的,但您永远不会知道某些浏览器或链接处理程序(如Google)如何处理它。我认为这是一个糟糕的网址时与laravel。 –
感谢您的回答,现在laravel这是一个糟糕的网址,所以我不能用双斜杠做网址。 –