本文介绍了Laravel路由,有很多可能性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
搜索了一段时间后,无法找到答案.
Been searching for a while and can't find an answer on if this is possible.
我要创建的一个URL.会是
One URL I am trying to make. would be
/location/province-name/city/category
省名只有几个选项.有没有办法设置它,使类似的东西行得通?
The province name only has a few options. Is there a way to set it up so something like this would work?
/{bc or ab or mn or etc}/{cityname}/{category}
这有意义吗?
推荐答案
您可以使用模式
routes/web.php
Route::pattern('province', '(bc|ab|mn|etc)');
Route::get('/location/{province}/{city}/{category}', function ($province, $city, $category) {
// TODO do something with your route
});
这篇关于Laravel路由,有很多可能性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!