FormRequest
class FormRequest extends Request implements ValidatesWhenResolved
Traits
Provides default implementation of ValidatesWhenResolved contract.
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected string | $json | The decoded JSON content for the request. |
from Request |
protected array | $convertedFiles | All of the converted files for the request. |
from Request |
protected Closure | $userResolver | The user resolver callback. |
from Request |
protected Closure | $routeResolver | The route resolver callback. |
from Request |
protected Container | $container | The container instance. |
|
protected Redirector | $redirector | The redirector instance. |
|
protected string | $redirect | The URI to redirect to if validation fails. |
|
protected string | $redirectRoute | The route to redirect to if validation fails. |
|
protected string | $redirectAction | The controller action to redirect to if validation fails. |
|
protected string | $errorBag | The key to be used for the view error bag. |
|
protected array | $dontFlash | The input keys that should not be flashed on redirect. |
Methods
Determine if the given content types match.
Determine if the current request probably expects a JSON response.
Determine if the current request is asking for JSON in return.
Determines whether the current requests accepts a given content type.
Return the most suitable content type from the given array based on content negotiation.
Get the data format expected in the response.
Retrieve an old input item.
Flash only some of the input to the session.
Flash only some of the input to the session.
Retrieve a server variable from the request.
Retrieve a header from the request.
Determine if the request contains a given input item key.
Determine if the request contains a non-empty value for an input item.
Determine if the given input key is an empty string for "has".
Retrieve an input item from the request.
Get a subset containing the provided keys with values from the input data.
Get all of the input except for a specified array of items.
Intersect an array of items with the input data.
Retrieve a query string item from the request.
Retrieve a cookie from the request.
Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles.
Check that the given file is a valid file instance.
Retrieve a file from the request.
Retrieve a parameter item from a given source.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Get the full URL for the request with the added query string parameters.
Get a segment from the URI (1 based index).
Determine if the current request URL and query string matches a pattern.
Get the JSON payload for the request.
Create an Illuminate request from a Symfony instance.
{@inheritdoc}
Filter the given array of files, removing any empty values.
Get the route handling the request.
Get the validator instance for the request.
Determine if the request passes the authorization check.
Handle a failed authorization attempt.
Get data to be validated from the request.
Get the proper failed validation response for the request.
Get the URL to redirect to on a validation error.
Get custom messages for validator errors.
Get custom attributes for validator errors.
Details
in
InteractsWithContentTypes at line 16
static bool
matchesType(string $actual, string $type)
Determine if the given content types match.
in
InteractsWithContentTypes at line 32
bool
isJson()
Determine if the request is sending JSON.
in
InteractsWithContentTypes at line 42
bool
expectsJson()
Determine if the current request probably expects a JSON response.
in
InteractsWithContentTypes at line 52
bool
wantsJson()
Determine if the current request is asking for JSON in return.
in
InteractsWithContentTypes at line 65
bool
accepts(string|array $contentTypes)
Determines whether the current requests accepts a given content type.
in
InteractsWithContentTypes at line 96
string|null
prefers(string|array $contentTypes)
Return the most suitable content type from the given array based on content negotiation.
in
InteractsWithContentTypes at line 126
bool
acceptsJson()
Determines whether a request accepts JSON.
in
InteractsWithContentTypes at line 136
bool
acceptsHtml()
Determines whether a request accepts HTML.
in
InteractsWithContentTypes at line 147
string
format(string $default = 'html')
Get the data format expected in the response.
in
InteractsWithFlashData at line 14
string|array
old(string $key = null, string|array|null $default = null)
Retrieve an old input item.
in
InteractsWithFlashData at line 24
void
flash()
Flash the input for the current request to the session.
in
InteractsWithFlashData at line 35
void
flashOnly(array|mixed $keys)
Flash only some of the input to the session.
in
InteractsWithFlashData at line 48
void
flashExcept(array|mixed $keys)
Flash only some of the input to the session.
in
InteractsWithFlashData at line 60
void
flush()
Flush all of the old input from the session.
in
InteractsWithInput at line 19
string|array
server(string $key = null, string|array|null $default = null)
Retrieve a server variable from the request.
in
InteractsWithInput at line 30
bool
hasHeader(string $key)
Determine if a header is set on the request.
in
InteractsWithInput at line 42
string|array
header(string $key = null, string|array|null $default = null)
Retrieve a header from the request.
in
InteractsWithInput at line 52
string|null
bearerToken()
Get the bearer token from the request headers.
in
InteractsWithInput at line 67
bool
exists(string|array $key)
Determine if the request contains a given input item key.
in
InteractsWithInput at line 88
bool
has(string|array $key)
Determine if the request contains a non-empty value for an input item.
in
InteractsWithInput at line 107
protected bool
isEmptyString(string $key)
Determine if the given input key is an empty string for "has".
in
InteractsWithInput at line 119
array
all()
Get all of the input and files for the request.
in
InteractsWithInput at line 131
string|array
input(string $key = null, string|array|null $default = null)
Retrieve an input item from the request.
in
InteractsWithInput at line 144
array
only(array|mixed $keys)
Get a subset containing the provided keys with values from the input data.
in
InteractsWithInput at line 165
array
except(array|mixed $keys)
Get all of the input except for a specified array of items.
in
InteractsWithInput at line 182
array
intersect(array|mixed $keys)
Intersect an array of items with the input data.
in
InteractsWithInput at line 194
string|array
query(string $key = null, string|array|null $default = null)
Retrieve a query string item from the request.
in
InteractsWithInput at line 205
bool
hasCookie(string $key)
Determine if a cookie is set on the request.
in
InteractsWithInput at line 217
string|array
cookie(string $key = null, string|array|null $default = null)
Retrieve a cookie from the request.
in
InteractsWithInput at line 227
array
allFiles()
Get an array of all of the files on the request.
in
InteractsWithInput at line 242
protected array
convertUploadedFiles(array $files)
Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles.
in
InteractsWithInput at line 261
bool
hasFile(string $key)
Determine if the uploaded data contains a file.
in
InteractsWithInput at line 282
protected bool
isValidFile(mixed $file)
Check that the given file is a valid file instance.
in
InteractsWithInput at line 294
UploadedFile|array|null
file(string $key = null, mixed $default = null)
Retrieve a file from the request.
in
InteractsWithInput at line 307
protected string|array
retrieveItem(string $source, string $key, string|array|null $default)
Retrieve a parameter item from a given source.
in
Macroable at line 24
static void
macro(string $name, callable $macro)
Register a custom macro.
in
Macroable at line 35
static bool
hasMacro(string $name)
Checks if macro is registered.
in
Macroable at line 49
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 71
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
in
Request at line 55
static Request
capture()
Create a new Illuminate HTTP request from server variables.
in
Request at line 67
$this
instance()
Return the Request instance.
in
Request at line 77
string
method()
Get the request method.
in
Request at line 87
string
root()
Get the root URL for the application.
in
Request at line 97
string
url()
Get the URL (no query string) for the request.
in
Request at line 107
string
fullUrl()
Get the full URL for the request.
in
Request at line 122
string
fullUrlWithQuery(array $query)
Get the full URL for the request with the added query string parameters.
in
Request at line 136
string
path()
Get the current path info for the request.
in
Request at line 148
string
decodedPath()
Get the current encoded path info for the request.
in
Request at line 160
string|null
segment(int $index, string|null $default = null)
Get a segment from the URI (1 based index).
in
Request at line 170
array
segments()
Get all of the segments for the request path.
in
Request at line 184
bool
is()
Determine if the current request URI matches a pattern.
in
Request at line 201
bool
routeIs(string $name)
Check if the route name matches the given string.
in
Request at line 211
bool
fullUrlIs()
Determine if the current request URL and query string matches a pattern.
in
Request at line 229
bool
ajax()
Determine if the request is the result of an AJAX call.
in
Request at line 239
bool
pjax()
Determine if the request is the result of an PJAX call.
in
Request at line 249
bool
secure()
Determine if the request is over HTTPS.
in
Request at line 259
string
ip()
Get the client IP address.
in
Request at line 269
array
ips()
Get the client IP addresses.
in
Request at line 279
string
userAgent()
Get the client user agent.
in
Request at line 290
void
merge(array $input)
Merge new input into the current request's input array.
in
Request at line 301
void
replace(array $input)
Replace the input for the current request.
in
Request at line 313
mixed
json(string $key = null, mixed $default = null)
Get the JSON payload for the request.
in
Request at line 331
protected ParameterBag
getInputSource()
Get the input source for the request.
in
Request at line 346
static Request
createFromBase(Request $request)
Create an Illuminate request from a Symfony instance.
in
Request at line 369
duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{@inheritdoc}
in
Request at line 380
protected mixed
filterFiles(mixed $files)
Filter the given array of files, removing any empty values.
in
Request at line 421
void
setLaravelSession(Session $session)
Set the session instance on the request.
in
Request at line 432
mixed
user(string|null $guard = null)
Get the user making the request.
in
Request at line 444
Route|object|string
route(string|null $param = null)
Get the route handling the request.
in
Request at line 462
string
fingerprint()
Get a unique fingerprint for the request / route / IP address.
in
Request at line 479
$this
setJson(array $json)
Set the JSON payload for the request.
in
Request at line 541
array
toArray()
Get all of the input and files for the request.
in
Request at line 552
bool
offsetExists(string $offset)
Determine if the given offset exists.
in
Request at line 563
mixed
offsetGet(string $offset)
Get the value at the given offset.
in
Request at line 575
void
offsetSet(string $offset, mixed $value)
Set the value at the given offset.
in
Request at line 586
void
offsetUnset(string $offset)
Remove the value at the given offset.
in
Request at line 597
bool
__isset(string $key)
Check if an input element is set on the request.
in
Request at line 608
mixed
__get(string $key)
Get an input element from the request.
in
ValidatesWhenResolvedTrait at line 15
void
validate()
Validate the class instance.
in
ValidatesWhenResolvedTrait at line 33
protected void
prepareForValidation()
Prepare the data for validation.
at line 74
protected Validator
getValidatorInstance()
Get the validator instance for the request.
at line 123
protected void
failedValidation(Validator $validator)
Handle a failed validation attempt.
at line 183
protected bool
passesAuthorization()
Determine if the request passes the authorization check.
at line 199
protected void
failedAuthorization()
Handle a failed authorization attempt.
at line 97
protected Validator
createDefaultValidator(Factory $factory)
Create the default validator instance.
at line 110
protected array
validationData()
Get data to be validated from the request.
at line 136
Response
response(array $errors)
Get the proper failed validation response for the request.
at line 153
protected array
formatErrors(Validator $validator)
Format the errors from the given Validator instance.
at line 163
protected string
getRedirectUrl()
Get the URL to redirect to on a validation error.
at line 209
array
messages()
Get custom messages for validator errors.
at line 219
array
attributes()
Get custom attributes for validator errors.
at line 230
$this
setRedirector(Redirector $redirector)
Set the Redirector instance.
at line 243
$this
setContainer(Container $container)
Set the container implementation.