2015-10-15 226 views
1

我知道如何在路由约束使用正则表达式,但我想用使用固定的值,而不是正则表达式是这样的:路由参数在laravel 5.1

Route::get('{param}/delete/{id}',array(
    'as' => 'delete-post', 
    'uses' => '[email protected]' 
))->where(['param',['post','page'],'id'=>'[0-9]+']); 

当我尝试这一点,我得到这样的错误
Routing requirement for "param" must be a string.

我要的是param参数的值是固定的,它应该是postpage。那么,我该如何达到上述目标呢?

回答

0

您可以使用正则表达式藏汉:

Route::get('{param}/delete/{id}',array(
    'as' => 'delete-post', 
    'uses' => '[email protected]' 
))->where(['param' => 'post|page', 'id'=>'[0-9]+']); 
+0

谢谢老兄,它解决的问题 – sixFingersMan