mercredi 17 janvier 2018

Is there a way to ignore the subdomain value in subdomain routing

According to the documentation, if I use subdomain routing for multiple subdomains, I have to pass the subdomain as a first argument of callbacks functions and controllers methods

Route::domain('{sub}.example.org')->group(function () {
    Route::get('a', function ($sub) { /* ... */ });
    Route::get('b', function ($sub) { /* ... */ });
    Route::get('c/{c}', function ($sub, $c) { /* ... */ });
    Route::get('d/{d}', function ($sub, $d) { /* ... */ });
});

In other word I have to carry the $sub variable everywhere. Assuming I don't care about its value, can I avoid this and just do something like this(this does not work for multiple argument):

Route::domain('{sub}.example.org')->group(function () {
    Route::get('a', function () { /* ... */ });
    Route::get('b', function () { /* ... */ });
    Route::get('c/{c}', function ($c) { /* ... */ });
    Route::get('d/{d}', function ($d) { /* ... */ });
});

If I do this $c and $d will be the value of the subdomain.

Assuming I don't care about the subdomain value and I have many routes, is there a way to ignore it?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mFEKko
via IFTTT

Aucun commentaire:

Enregistrer un commentaire