vendredi 22 juin 2018

Unexpected behaviour when passing URL param to method from within a domain group

I have a route group, as I want to place a bunch of routes under a dynamic subdomain.

The problem is that when I go to a URL that has a second parameter (the first being the sub domain name), it's the sub domain name parameter that get's passed to my controller method.

My Routes setup:

Route::group([ 'domain' => '{sub_domain_name}.example.com'], function () {

    Route::get('/client/{id}', 'ClientsController@show');

});

The controller method:

public function show($id) {
        echo $id; 
        // get view etc
}

If I go the the URL http://hello.example.com/client/5 I expect the value of $id in the show() method to be 5. But, it's actually hello.

What am I doing wrong?

Laravel 5.6

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire