Php 拉威尔合并路线

Php 拉威尔合并路线,php,laravel,laravel-routing,Php,Laravel,Laravel Routing,有没有办法把这两条路线结合起来 Route::get('project/(:any)', 'dashboard.project@(:1)'); Route::get('project/(:any)/(:any)', 'dashboard.project@(:1)'); 我这样问是因为第二条路线,我必须添加它,以便以下请求能够工作: site.com/project/new => method site.com/project/view/12351326 => method and

有没有办法把这两条路线结合起来

Route::get('project/(:any)', 'dashboard.project@(:1)');
Route::get('project/(:any)/(:any)', 'dashboard.project@(:1)');
我这样问是因为第二条路线,我必须添加它,以便以下请求能够工作:

site.com/project/new => method
site.com/project/view/12351326 => method and parameter

您可以在
get()
方法的第一个参数中使用regex来组合这些参数

请参阅文档中的部分

类似的方法可能会奏效:

Route::get('project/{name}', function($name)
{
    //
})
->where('name', '[A-Za-z0-9\/]+');

其中正则表达式将匹配URL,例如
/projects/something/anywhere
。但是,这可能过于宽松-它还将匹配
/projects/any/number/of/url/segments
。但我相信更多的正则表达式有助于制定更好的约束条件,以更接近您所寻找的内容。

是的,我计划稍后将其与更复杂的逻辑结合起来(facebook就是这样做的),但由于时间总是一个问题,因为我不得不走另一条路。。。目前,Laravel3中是否有
->where()
?因为它对meDocs不起作用,它还活着。where()确实存在,但需要位于从
DB::table('some_table')
返回的查询对象上
DB::table('my_table')->where('id',1)->get()
噢,我不知道,但我有一个
docs
bundle副本,并用它来搜索信息。这就是为什么我问L3是否支持路由的
位置。