我的路由在laravel中工作不正常

时间:2017-09-08 12:31:44

标签: laravel routing

以下是我在http / routes.php

中提到的两条路线
Route::get('/{buy_type}-property/{type}-in-{city}/{location}/project/{projname}/{section}', 'APP\DetectHookController@detectProjectcase4')->where('projname', '[A-Za-z0-9_\-A-Za-z0-9_\-]+')->where('location','[A-Za-z0-9_\-A-Za-z0-9_\-]+')->where('section', '[A-Za-z0-9_\-A-Za-z0-9_\-]+');

第二个是

Route::get('/{buy_type}-property/{type}-in-{city}/{location}/project/{clustername}/{projname}', array( 'as' => 'project-with-cluster', 'uses' => 'APP\DetectHookController@detectProjectcase2'))->where('projname', '[A-Za-z0-9_\-A-Za-z0-9_\-]+')->where('location','[A-Za-z0-9_\-A-Za-z0-9_\-]+');

我希望在第一个路由中基于{section}参数的条件路由。 当它应该被调用时,第二个没有调用,因为两个路由具有相同的参数。有人建议我,因为我无助近一个星期。

1 个答案:

答案 0 :(得分:0)

您可以将路线重新构建为:

Route::get('/{buy_type}-property/{type}-in-{city}/{location}/project/{projname}/cluster/{clustername}', array( 'as' => 'project-with-cluster', 'uses' => 'APP\DetectHookController@detectProjectcase2'))->where('projname', '[A-Za-z0-9_\-A-Za-z0-9_\-]+')->where('location','[A-Za-z0-9_\-A-Za-z0-9_\-]+');