mardi 1 août 2017

Laravel: Optional route prefix parameter

I'm currently working on a multi-site application (one codebase for multiple (sub)sites) and I would love to leverage route caching, but currently I'm hardcoding a prefix instead of dynamically determining it.

When trying to do this I'm running into an issue which I've illustrated below:

Route::group(['prefix' => '{subsite}', 'subdomain' => '{site}.domain.tld'], function () {
    Route::get('blog', 'BlogController@index')->name('blog.index');
});

When accessing a subsite like http://ift.tt/2ufaWNt this all works fine, but it doesn't work anymore when not accessing a subsite like http://ift.tt/2tZnvkR, as it will now think that the prefix is 'blog'.

Is there any way to allow the 'subsite' parameter to be empty or skipped?

Thanks!



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

Aucun commentaire:

Enregistrer un commentaire