【发布时间】:2016-06-26 15:38:16
【问题描述】:
我已经使用xampp 在我的本地主机上设置了一些子域。
这是我的子域路由:
Route::group(['domain' => '{subdomain}.localhost'], function(){
Route::get('home', array('as'=>'sub.home', 'uses'=>'SubdomainController@home')
Route::get('gallery/{id}', array('as'=>'sub.gallery', 'uses'=>'SubdomainController@gallery'));
});
这些是我的链接:
{{ URL::route('sub.home', array($subdomain)) }}
{{ URL::route('sub.gallery', array($subdomain,2)) }}
“home-route”按预期工作,但无论我做什么,gallery-route 参数“2”都不会传递给方法,而是显示子域的名称。
谁能指出我正确的方向。
编辑 当我将 $subdomain 添加到该方法时,我得到了正确的 $id。 现在的新问题是如何在不将 subdomain-param 注入每个方法的情况下做到这一点。
public function gallery($subdomain, $id) {
die($id);//output is now "2"
}
【问题讨论】:
-
你试过
{{ URL::route('sub.gallery', ['subdomain'=>$subdomain,'id'=>2]) }}吗? -
我做了,但没有改变任何事情。
标签: laravel parameters routes subdomain