Laravel 5.2: Creating a custom route function - extending route

Viewed 1914

So basically, I want to create my own Route::custom function.

This is because I've been using the same groups and middleware for several routes throughout the site (I'm also using modules with subdomains, so we're talking about saving 5-6 lines of code per route)

All I want is for Route::custom to just call two or three other Route functions. For example:

Route::Module('forum') to be replaced with

Route::group(['middleware' => ['web','auth'], 'domain' => 'forum.' . env('SITE_DOMAIN', 'example.com')], function () {
    Route::group(['middleware' => 'permission:access.forum'], function () {
        Route::get('/', function () {
            return view('forum::forum.index');
        })->name("forum.index");
    });
});
2 Answers
Related