Laravel 4 Laravel 4-获取命名路由的URI
有人知道如何获取命名路由的uri吗?大概是这样的:Laravel 4 Laravel 4-获取命名路由的URI,laravel-4,routing,Laravel 4,Routing,有人知道如何获取命名路由的uri吗?大概是这样的: $sourceUri = Route::getNamedRoute('nameOfMyRoute')->getPath(); //this doesn't work of course $targetUri = Route::getCurrentRoute()->getPath(); //this DOES work return sourceUri === targetUri; 我希望这样做的原因是确定客户端请求的当前路由是否
$sourceUri = Route::getNamedRoute('nameOfMyRoute')->getPath(); //this doesn't work of course
$targetUri = Route::getCurrentRoute()->getPath(); //this DOES work
return sourceUri === targetUri;
我希望这样做的原因是确定客户端请求的当前路由是否与给定的命名路由相同,如下所示:
$sourceUri = Route::getNamedRoute('nameOfMyRoute')->getPath(); //this doesn't work of course
$targetUri = Route::getCurrentRoute()->getPath(); //this DOES work
return sourceUri === targetUri;
使用以下命令:
$url = route('routeName', $params);
这一个可能会起作用:
Route::getRoutes()->getByName('name.of.your.route')->getUri();
route('routeName')
返回整个url(即http://subdomain.example.com/uri
)。我只希望uri采用getPath()
或uri()
do.beauty的方式。这起作用了:Route::getRoutes()->getbyName('routeName')->getUri()
。虽然不熟悉dd
函数,但是.dd是var_dump($stuff)的Laravel助手;死亡