Laravel 4.2 subdomain route-parameter

Viewed 926

i've setup some subdomains on my localhost using xampp. this is my subdomain-routes:

    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'));
});

These are my links:

{{ URL::route('sub.home', array($subdomain)) }}
{{ URL::route('sub.gallery', array($subdomain,2)) }}

The "home-route" works as expected, but whatever i do, the gallery-route parameter "2" is not passed to the method, instead it shows the name of the subdomain.

Can anyone point my to the right direction.

E D I T when i add $subdomain to the method, i get the correct $id. Now the new question is how to do this without injecting the subdomain-param to every method.

public function gallery($subdomain, $id) {
    die($id);//output is now "2"
}
1 Answers
Related