Laravel - Routing - Dependency Injection

You may type-hint any dependencies required by your route in your route's callback signature. The declared dependencies will automatically be resolved and injected into the callback by the Laravel service container. For example, you may type-hint the Illuminate\Http\Request class to have the current HTTP request automatically injected into your route callback:



use Illuminate\Http\Request;

Route::get('/users', function (Request $request) {
    // ...
});