Laravel - URL Generation - Default Values

For some applications, you may wish to specify request-wide default values for certain URL parameters. For example, imagine many of your routes define a {locale} parameter:

    
    Route::get('/{locale}/posts', function () {
        //
    })->name('post.index');
	

It is cumbersome to always pass the locale every time you call the route helper. So, you may use the URL::defaults method to define a default value for this parameter that will always be applied during the current request. You may wish to call this method from a route middleware so that you have access to the current request:

    
     $request->user()->locale]);
    
            return $next($request);
        }
    }
	

Once the default value for the locale parameter has been set, you are no longer required to pass its value when generating URLs via the route helper.