$request->path();
// verify that the incoming request path matches a given pattern
if ($request->is('admin/*')) {
//
}
// Without Query String...
$url = $request->url();
// With Query String...
$url = $request->fullUrl();
// method
if ($request->isMethod('post')) {
//
}
By default, Laravel includes the TrimStrings and ConvertEmptyStringsToNull middleware in your application's global middleware stack. These middleware will automatically trim all incoming string fields on the request, as well as convert any empty string fields to null.
$input = $request->all(); // may same with $request->input();
// default value 'Sally'
$name = $request->input('name', 'Sally');
When working with forms that contain array inputs, use "dot" notation to access the arrays:
$name = $request->input('products.0.name');
$names = $request->input('products.*.name');
While the input method retrieves values from entire request payload (including the query string), the query method will only retrieve values from the query string:
$name = $request->query('name');
or $name = $request->name; // dynamic properties
When using dynamic properties, Laravel will first look for the parameter's value in the request payload. If it is not present, Laravel will search for the field in the route parameters.
if ($request->has('name')) {
//
}
If you would like to determine if a value is present on the request and is not empty, you may use the filled method:
if ($request->filled('name')) {
//
}
Retrieving Old Input
$username = $request->old('username');
<input type="text" name="username" value="{{ old('username') }}">