我正在try 做一些不同的事情,但我找不到任何方法.也许我的方法是错误的,但不管怎样,我想我可能会在这里找到一些帮助.
我有一个Laravel 5项目,您知道如何使用以下方法获得当前路由名称:
\Request::route()->getName();
所以我实际上想做完全相反的事情.也许不是完全相反,但我需要的是根据我给那个路由的名称检索我的路由URL.
我的路由.php:
Route::any('/hos', "HospitalController@index")->name("hospital");
在我的控制器中,我不知道如何操作,甚至不知道是否可能:
// I have no idea if this is possible but thats what I'm trying to accomplish
$my_route_url = \Request::route()->getURLByName("hospital");
echo $my_route_url; // this would echo: "/hos"
I might be using the wrong approach here so maybe you guys can help me out and shine some light on the issue.
谢谢!