dongzi0857
2015-10-15 08:58
浏览 36
已采纳

laravel 5.1中的路由参数

I know how to use regular expression on route constraints but I want to use use fixed value instead of regular expression like this :

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

When I try this , i get the error like
Routing requirement for "param" must be a string.

What I want is the value of param parameter is to be fixed and it should be either post or page . So, how can I achieve like above ?

图片转代码服务由CSDN问答提供 功能建议

我知道如何在路径约束上使用正则表达式,但我想使用固定值而不是像这样的正则表达式 :</ p>

  Route :: get('{param} / delete / {id}',array(
'as'=&gt;'delete-post',
  'uses'=&gt;'MainController @ delete'
)) - &gt; where(['param',['post','page'],'id'=&gt;'[0-9] +']  ); 
 </ code> </ pre> 
 
 

当我尝试这个时,我得到的错误就像

“param”的路由要求必须是一个字符串。</ code> </ p>

我想要的是修复 param </ code>参数的值,它应该是 post </ code>或 page < / code>。 那么,我怎样才能实现上述目标呢? </ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题