Laravel - Requests - Accessing The Request
To obtain an instance of the current HTTP request via dependency injection, you should type-hint the Illuminate\Http\Request
class on your route closure or controller method. The incoming request instance will automatically be injected by the Laravel service container:
input('name');
//
}
}
As mentioned, you may also type-hint the Illuminate\Http\Request
class on a route closure. The service container will automatically inject the incoming request into the closure when it is executed:
use Illuminate\Http\Request;
Route::get('/', function (Request $request) {
//
});