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");
});
});
You can extends laravel default facade then add static method as you want.
Notice: You must replace route facade config in config/app.php
to your custom facade class.
Example here