FormRequest
class FormRequest extends Request implements ValidatesWhenResolved (View source)
Traits
ValidatesWhenResolvedTrait | Provides default implementation of ValidatesWhenResolved contract. |
Macroable |
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
static void | macro(string $name, callable $macro) Register a custom macro. | from Macroable |
static bool | hasMacro(string $name) Checks if macro is registered. | from Macroable |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
static Request | capture() Create a new Illuminate HTTP request from server variables. | from Request |
$this | instance() Return the Request instance. | from Request |
string | method() Get the request method. | from Request |
string | root() Get the root URL for the application. | from Request |
string | url() Get the URL (no query string) for the request. | from Request |
string | fullUrl() Get the full URL for the request. | from Request |
string | fullUrlWithQuery(array $query) Get the full URL for the request with the added query string parameters. | from Request |
string | path() Get the current path info for the request. | from Request |
string | decodedPath() Get the current encoded path info for the request. | from Request |
string|null | segment(int $index, string|null $default = null) Get a segment from the URI (1 based index). | from Request |
array | segments() Get all of the segments for the request path. | from Request |
bool | is() Determine if the current request URI matches a pattern. | from Request |
bool | fullUrlIs() Determine if the current request URL and query string matches a pattern. | from Request |
bool | ajax() Determine if the request is the result of an AJAX call. | from Request |
bool | pjax() Determine if the request is the result of an PJAX call. | from Request |
bool | secure() Determine if the request is over HTTPS. | from Request |
string | ip() Returns the client IP address. | from Request |
array | ips() Returns the client IP addresses. | from Request |
bool | exists(string|array $key) Determine if the request contains a given input item key. | from Request |
bool | has(string|array $key) Determine if the request contains a non-empty value for an input item. | from Request |
bool | isEmptyString(string $key) Determine if the given input key is an empty string for "has". | from Request |
array | all() Get all of the input and files for the request. | from Request |
string|array | input(string $key = null, string|array|null $default = null) Retrieve an input item from the request. | from Request |
array | only(array|mixed $keys) Get a subset containing the provided keys with values from the input data. | from Request |
array | except(array|mixed $keys) Get all of the input except for a specified array of items. | from Request |
array | intersect(array|mixed $keys) Intersect an array of items with the input data. | from Request |
string|array | query(string $key = null, string|array|null $default = null) Retrieve a query string item from the request. | from Request |
bool | hasCookie(string $key) Determine if a cookie is set on the request. | from Request |
string|array | cookie(string $key = null, string|array|null $default = null) Retrieve a cookie from the request. | from Request |
array | allFiles() Get an array of all of the files on the request. | from Request |
array | convertUploadedFiles(array $files) Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles. | from Request |
UploadedFile|array|null | file(string $key = null, mixed $default = null) Retrieve a file from the request. | from Request |
bool | hasFile(string $key) Determine if the uploaded data contains a file. | from Request |
bool | isValidFile(mixed $file) Check that the given file is a valid file instance. | from Request |
bool | hasHeader(string $key) Determine if a header is set on the request. | from Request |
string|array | header(string $key = null, string|array|null $default = null) Retrieve a header from the request. | from Request |
string|array | server(string $key = null, string|array|null $default = null) Retrieve a server variable from the request. | from Request |
string|array | old(string $key = null, string|array|null $default = null) Retrieve an old input item. | from Request |
void | flash(string $filter = null, array $keys = []) Flash the input for the current request to the session. | from Request |
void | flashOnly(array|mixed $keys) Flash only some of the input to the session. | from Request |
void | flashExcept(array|mixed $keys) Flash only some of the input to the session. | from Request |
void | flush() Flush all of the old input from the session. | from Request |
string|array | retrieveItem(string $source, string $key, string|array|null $default) Retrieve a parameter item from a given source. | from Request |
void | merge(array $input) Merge new input into the current request's input array. | from Request |
void | replace(array $input) Replace the input for the current request. | from Request |
mixed | json(string $key = null, mixed $default = null) Get the JSON payload for the request. | from Request |
ParameterBag | getInputSource() Get the input source for the request. | from Request |
static bool | matchesType(string $actual, string $type) Determine if the given content types match. | from Request |
bool | isJson() Determine if the request is sending JSON. | from Request |
bool | expectsJson() Determine if the current request probably expects a JSON response. | from Request |
bool | wantsJson() Determine if the current request is asking for JSON in return. | from Request |
bool | accepts(string|array $contentTypes) Determines whether the current requests accepts a given content type. | from Request |
string|null | prefers(string|array $contentTypes) Return the most suitable content type from the given array based on content negotiation. | from Request |
bool | acceptsJson() Determines whether a request accepts JSON. | from Request |
bool | acceptsHtml() Determines whether a request accepts HTML. | from Request |
string | format(string $default = 'html') Get the data format expected in the response. | from Request |
string|null | bearerToken() Get the bearer token from the request headers. | from Request |
static Request | createFromBase(Request $request) Create an Illuminate request from a Symfony instance. | from Request |
duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) {@inheritdoc} | from Request | |
mixed | filterFiles(mixed $files) Filter the given array of files, removing any empty values. | from Request |
Store | session() Get the session associated with the request. | from Request |
mixed | user(string|null $guard = null) Get the user making the request. | from Request |
Route|object|string | route(string|null $param = null) Get the route handling the request. | from Request |
string | fingerprint() Get a unique fingerprint for the request / route / IP address. | from Request |
Closure | getUserResolver() Get the user resolver callback. | from Request |
$this | setUserResolver(Closure $callback) Set the user resolver callback. | from Request |
Closure | getRouteResolver() Get the route resolver callback. | from Request |
$this | setRouteResolver(Closure $callback) Set the route resolver callback. | from Request |
array | toArray() Get all of the input and files for the request. | from Request |
bool | offsetExists(string $offset) Determine if the given offset exists. | from Request |
mixed | offsetGet(string $offset) Get the value at the given offset. | from Request |
void | offsetSet(string $offset, mixed $value) Set the value at the given offset. | from Request |
void | offsetUnset(string $offset) Remove the value at the given offset. | from Request |
bool | __isset(string $key) Check if an input element is set on the request. | from Request |
mixed | __get(string $key) Get an input element from the request. | from Request |
void | validate() Validate the class instance. | from ValidatesWhenResolvedTrait |
void | prepareForValidation() Prepare the data for validation. | from ValidatesWhenResolvedTrait |
Validator | getValidatorInstance() Get the validator instance for the request. | |
void | failedValidation(Validator $validator) Handle a failed validation attempt. | |
bool | passesAuthorization() Determine if the request passes the authorization check. | |
void | failedAuthorization() Handle a failed authorization attempt. | |
array | validationData() Get data to be validated from the request. | |
Response | response(array $errors) Get the proper failed validation response for the request. | |
Response | forbiddenResponse() Get the response for a forbidden operation. | |
array | formatErrors(Validator $validator) Format the errors from the given Validator instance. | |
string | getRedirectUrl() Get the URL to redirect to on a validation error. | |
$this | setRedirector(Redirector $redirector) Set the Redirector instance. | |
$this | setContainer(Container $container) Set the container implementation. | |
array | messages() Get custom messages for validator errors. | |
array | attributes() Get custom attributes for validator errors. |
Details
static void macro(string $name, callable $macro)
Register a custom macro.
static bool hasMacro(string $name)
Checks if macro is registered.
static mixed __callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed __call(string $method, array $parameters)
Dynamically handle calls to the class.
static Request capture()
Create a new Illuminate HTTP request from server variables.
$this instance()
Return the Request instance.
string method()
Get the request method.
string root()
Get the root URL for the application.
string url()
Get the URL (no query string) for the request.
string fullUrl()
Get the full URL for the request.
string fullUrlWithQuery(array $query)
Get the full URL for the request with the added query string parameters.
string path()
Get the current path info for the request.
string decodedPath()
Get the current encoded path info for the request.
string|null segment(int $index, string|null $default = null)
Get a segment from the URI (1 based index).
array segments()
Get all of the segments for the request path.
bool is()
Determine if the current request URI matches a pattern.
bool fullUrlIs()
Determine if the current request URL and query string matches a pattern.
bool ajax()
Determine if the request is the result of an AJAX call.
bool pjax()
Determine if the request is the result of an PJAX call.
bool secure()
Determine if the request is over HTTPS.
string ip()
Returns the client IP address.
array ips()
Returns the client IP addresses.
bool exists(string|array $key)
Determine if the request contains a given input item key.
bool has(string|array $key)
Determine if the request contains a non-empty value for an input item.
protected bool isEmptyString(string $key)
Determine if the given input key is an empty string for "has".
array all()
Get all of the input and files for the request.
string|array input(string $key = null, string|array|null $default = null)
Retrieve an input item from the request.
array only(array|mixed $keys)
Get a subset containing the provided keys with values from the input data.
array except(array|mixed $keys)
Get all of the input except for a specified array of items.
array intersect(array|mixed $keys)
Intersect an array of items with the input data.
string|array query(string $key = null, string|array|null $default = null)
Retrieve a query string item from the request.
bool hasCookie(string $key)
Determine if a cookie is set on the request.
string|array cookie(string $key = null, string|array|null $default = null)
Retrieve a cookie from the request.
array allFiles()
Get an array of all of the files on the request.
protected array convertUploadedFiles(array $files)
Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles.
UploadedFile|array|null file(string $key = null, mixed $default = null)
Retrieve a file from the request.
bool hasFile(string $key)
Determine if the uploaded data contains a file.
protected bool isValidFile(mixed $file)
Check that the given file is a valid file instance.
bool hasHeader(string $key)
Determine if a header is set on the request.
string|array header(string $key = null, string|array|null $default = null)
Retrieve a header from the request.
string|array server(string $key = null, string|array|null $default = null)
Retrieve a server variable from the request.
string|array old(string $key = null, string|array|null $default = null)
Retrieve an old input item.
void flash(string $filter = null, array $keys = [])
Flash the input for the current request to the session.
void flashOnly(array|mixed $keys)
Flash only some of the input to the session.
void flashExcept(array|mixed $keys)
Flash only some of the input to the session.
void flush()
Flush all of the old input from the session.
protected string|array retrieveItem(string $source, string $key, string|array|null $default)
Retrieve a parameter item from a given source.
void merge(array $input)
Merge new input into the current request's input array.
void replace(array $input)
Replace the input for the current request.
mixed json(string $key = null, mixed $default = null)
Get the JSON payload for the request.
protected ParameterBag getInputSource()
Get the input source for the request.
static bool matchesType(string $actual, string $type)
Determine if the given content types match.
bool isJson()
Determine if the request is sending JSON.
bool expectsJson()
Determine if the current request probably expects a JSON response.
bool wantsJson()
Determine if the current request is asking for JSON in return.
bool accepts(string|array $contentTypes)
Determines whether the current requests accepts a given content type.
string|null prefers(string|array $contentTypes)
Return the most suitable content type from the given array based on content negotiation.
bool acceptsJson()
Determines whether a request accepts JSON.
bool acceptsHtml()
Determines whether a request accepts HTML.
string format(string $default = 'html')
Get the data format expected in the response.
string|null bearerToken()
Get the bearer token from the request headers.
static Request createFromBase(Request $request)
Create an Illuminate request from a Symfony instance.
duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{@inheritdoc}
protected mixed filterFiles(mixed $files)
Filter the given array of files, removing any empty values.
Store session()
Get the session associated with the request.
mixed user(string|null $guard = null)
Get the user making the request.
Route|object|string route(string|null $param = null)
Get the route handling the request.
string fingerprint()
Get a unique fingerprint for the request / route / IP address.
Closure getUserResolver()
Get the user resolver callback.
$this setUserResolver(Closure $callback)
Set the user resolver callback.
Closure getRouteResolver()
Get the route resolver callback.
$this setRouteResolver(Closure $callback)
Set the route resolver callback.
array toArray()
Get all of the input and files for the request.
bool offsetExists(string $offset)
Determine if the given offset exists.
mixed offsetGet(string $offset)
Get the value at the given offset.
void offsetSet(string $offset, mixed $value)
Set the value at the given offset.
void offsetUnset(string $offset)
Remove the value at the given offset.
bool __isset(string $key)
Check if an input element is set on the request.
mixed __get(string $key)
Get an input element from the request.
void validate()
Validate the class instance.
protected void prepareForValidation()
Prepare the data for validation.
protected Validator getValidatorInstance()
Get the validator instance for the request.
protected void failedValidation(Validator $validator)
Handle a failed validation attempt.
protected bool passesAuthorization()
Determine if the request passes the authorization check.
protected void failedAuthorization()
Handle a failed authorization attempt.
protected array validationData()
Get data to be validated from the request.
Response response(array $errors)
Get the proper failed validation response for the request.
Response forbiddenResponse()
Get the response for a forbidden operation.
protected array formatErrors(Validator $validator)
Format the errors from the given Validator instance.
protected string getRedirectUrl()
Get the URL to redirect to on a validation error.
$this setRedirector(Redirector $redirector)
Set the Redirector instance.
$this setContainer(Container $container)
Set the container implementation.
array messages()
Get custom messages for validator errors.
array attributes()
Get custom attributes for validator errors.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Foundation/Http/FormRequest.html