【发布时间】:2017-08-08 08:44:17
【问题描述】:
我需要按名称返回其他路由路径(类似于/home/{page?}),我试过Route()
https://laravel.com/api/5.1/Illuminate/Contracts/Routing/UrlGenerator.html#method_route
Route('home'); //return http://localhost/home
Route('home',[1]); //return http://localhost/home/1
Route('home',[1],false); //return /home/1
但是我需要返回系统路径:/home/{page?},而home不是当前路由,
谢谢,
更新:
路线定义:
Route::GET('home/{page?}' ,array('uses'=>'News@home', 'as'=>'home'));
【问题讨论】:
-
你能显示你的
routes/web.php文件,你定义了这条路线吗? -
@Jerodev 添加到问题
-
其他路由部分是什么意思?你想得到的确切字符串是什么?
-
我想得到这个
home/{page?},这不是当前请求的路线 -
请问您为什么想要这个?没有简单的方法可以做到这一点,您必须从应用程序路由器集合中获取它。