`laravel`的路由很强大
记得之前自己要写`nginx`重写规则,用`laravel`的路由非常方便
有没有办法控制路由`参数`的`类型`,比如值是数字还是字母
还有怎么限制参数的`取值范围`
限制参数类型
>Route::get('/test/{id}', 'IndexController@test')->where('id', '[0-9]+');
Route::get('/test/{id}/{page}', 'IndexController@list')->where(['id' => '[0-9]+', 'page' => '[0-9]+']);
Route::get('/test/{id}/{name}', 'IndexController@list')->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
限制参数取值范围
>Route::get('/tag/{name}', 'IndexController@tag')->where(['name', '阿里云|腾讯|日志|邮件|shell|php|laravel|vim|ssh|git|linux|python']);
Route::get('/tag/{name}/{page}', 'IndexController@tag')->where(['name'=>'阿里云|腾讯|日志|邮件|shell|php|laravel|vim|ssh|git|linux|python', 'page' =>'[0-9]+']);