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 ?
You can use regex aswell:
Route::get('{param}/delete/{id}',array(
'as' => 'delete-post',
'uses' => 'MainController@delete'
))->where(['param' => 'post|page', 'id'=>'[0-9]+']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.