我知道如何在路由约束上使用正则表达式,但我想使用固定值而不是像这样的正则表达式:
Route::get('{param}/delete/{id}',array(
'as' => 'delete-post',
'uses' => 'MainController@delete'
))->where(['param',['post','page'],'id'=>'[0-9]+']);
当我尝试这个时,我收到的错误就像是Routing requirement for "param" must be a string.
我想要的是param
参数的值是固定的,它应该是post
或page
。那么,我怎样才能实现上述目标呢?
答案 0 :(得分:0)
您可以使用正则表达式:
Route::get('{param}/delete/{id}',array(
'as' => 'delete-post',
'uses' => 'MainController@delete'
))->where(['param' => 'post|page', 'id'=>'[0-9]+']);