FormRequest
class FormRequest extends Request implements ValidatesWhenResolved (View source)
Traits
Provides default implementation of ValidatesWhenResolved contract.
Properties
| static protected array | $macros | The registered string macros.  | 
                from Macroable | 
| protected InputBag|null | $json | The decoded JSON content for the request.  | 
                from Request | 
| protected UploadedFile|UploadedFile[]> | $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 bool | $stopOnFirstFailure | Indicates whether validation should stop after the first rule failure.  | 
                |
| protected Validator | $validator | The validator instance.  | 
                
Methods
Filter the given array of rules into an array of rules that are included in precognitive headers.
Determine if the request is attempting to be precognitive.
Determine if the current request probably expects a JSON response.
Determine if the current request is asking for JSON.
Determines whether the current requests accepts a given content type.
Return the most suitable content type from the given array based on content negotiation.
Determine if the current request accepts any content type.
Determine if the given content types match.
Get the data format expected in the response.
Flash only some of the input to the session.
Flash only some of the input to the session.
Retrieve data from the instance.
Determine if the instance contains any of the given keys.
Apply the callback if the instance contains the given key.
Determine if the instance contains a non-empty value for the given key.
Determine if the instance contains an empty value for the given key.
Determine if the instance contains a non-empty value for any of the given keys.
Apply the callback if the instance contains a non-empty value for the given key.
Determine if the instance is missing a given key.
Apply the callback if the instance is missing the given key.
Determine if the given key is an empty string for "filled".
Retrieve data from the instance as a Stringable instance.
Retrieve data from the instance as a Stringable instance.
Retrieve data as a boolean value.
Retrieve data as an integer value.
Retrieve data as a float value.
Retrieve data from the instance as a Carbon instance.
Retrieve data from the instance as an enum.
Retrieve data from the instance as an array of enums.
Determine if the given enum class is backed.
Retrieve data from the instance as an array.
Retrieve data from the instance as a collection.
Get a subset containing the provided keys with values from the instance data.
Get all of the data except for a specified array of items.
Retrieve a server variable from the request.
Retrieve a header from the request.
Retrieve an input item from the request.
Retrieve input from the request as a Fluent object instance.
Retrieve a query string item from the request.
Retrieve a request payload item from the request.
Retrieve a cookie from the request.
Get an array of all of the files on 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.
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Mix another object into the class.
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 the full URL for the request without the given query string parameters.
Get a segment from the URI (1 based index).
Determine if the current request URL and query string match a pattern.
Merge new input into the request's input, but only when that key is missing from the request.
This method belongs to Symfony HttpFoundation and is not usually needed when using Laravel.
Get the JSON payload for the request.
Create a new request instance from the given Laravel request.
Create an Illuminate request from a Symfony instance.
{@inheritdoc}
Filter the given array of files, removing any empty values.
Set the default locale for the request instance.
Get the route handling the request.
No description
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 validation rules for this form request.
Get the URL to redirect to on a validation error.
Get a validated input container for the validated input.
Get the validated data from the request.
Get custom messages for validator errors.
Get custom attributes for validator errors.
Details
        
                            array
    filterPrecognitiveRules(array $rules)
        
    
    Filter the given array of rules into an array of rules that are included in precognitive headers.
        
                            bool
    isAttemptingPrecognition()
        
    
    Determine if the request is attempting to be precognitive.
        
                            bool
    isPrecognitive()
        
    
    Determine if the request is precognitive.
        
                            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.
        
                            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
    acceptsAnyContentType()
        
    
    Determine if the current request accepts any content type.
        
                            bool
    acceptsJson()
        
    
    Determines whether a request accepts JSON.
        
                            bool
    acceptsHtml()
        
    
    Determines whether a request accepts HTML.
        
                static            bool
    matchesType(string $actual, string $type)
        
    
    Determine if the given content types match.
        
                            string
    format(string $default = 'html')
        
    
    Get the data format expected in the response.
        
                            string|array|null
    old(string|null $key = null, Model|string|array|null $default = null)
        
    
    Retrieve an old input item.
        
                            void
    flash()
        
    
    Flash the input for the current request to the session.
        
                            void
    flashOnly(mixed $keys)
        
    
    Flash only some of the input to the session.
        
                            void
    flashExcept(mixed $keys)
        
    
    Flash only some of the input to the session.
        
                            void
    flush()
        
    
    Flush all of the old input from the session.
        
                            never
    dd(mixed ...$args)
        
    
    Dump the given arguments and terminate execution.
        
                            $this
    dump(mixed ...$args)
        
    
    Dump the given arguments.
        
            abstract                array
    all(mixed $keys = null)
        
    
    Retrieve all data from the instance.
        
            abstract        protected        mixed
    data(string|null $key = null, mixed $default = null)
        
    
    Retrieve data from the instance.
        
                            bool
    exists(string|array $key)
        
    
    Determine if the data contains a given key.
        
                            bool
    has(string|array $key)
        
    
    Determine if the data contains a given key.
        
                            bool
    hasAny(string|array $keys)
        
    
    Determine if the instance contains any of the given keys.
        
                            $this|mixed
    whenHas(string $key, callable $callback, callable|null $default = null)
        
    
    Apply the callback if the instance contains the given key.
        
                            bool
    filled(string|array $key)
        
    
    Determine if the instance contains a non-empty value for the given key.
        
                            bool
    isNotFilled(string|array $key)
        
    
    Determine if the instance contains an empty value for the given key.
        
                            bool
    anyFilled(string|array $keys)
        
    
    Determine if the instance contains a non-empty value for any of the given keys.
        
                            $this|mixed
    whenFilled(string $key, callable $callback, callable|null $default = null)
        
    
    Apply the callback if the instance contains a non-empty value for the given key.
        
                            bool
    missing(string|array $key)
        
    
    Determine if the instance is missing a given key.
        
                            $this|mixed
    whenMissing(string $key, callable $callback, callable|null $default = null)
        
    
    Apply the callback if the instance is missing the given key.
        
                    protected        bool
    isEmptyString(string $key)
        
    
    Determine if the given key is an empty string for "filled".
        
                            Stringable
    str(string $key, mixed $default = null)
        
    
    Retrieve data from the instance as a Stringable instance.
        
                            Stringable
    string(string $key, mixed $default = null)
        
    
    Retrieve data from the instance as a Stringable instance.
        
                            bool
    boolean(string|null $key = null, bool $default = false)
        
    
    Retrieve data as a boolean value.
Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
        
                            int
    integer(string $key, int $default = 0)
        
    
    Retrieve data as an integer value.
        
                            float
    float(string $key, float $default = 0.0)
        
    
    Retrieve data as a float value.
        
                            Carbon|null
    date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)
        
    
    Retrieve data from the instance as a Carbon instance.
        
                            TEnum|null
    enum(string $key, TEnum> $enumClass, TEnum|null $default = null)
        
    
    Retrieve data from the instance as an enum.
        
                            TEnum[]
    enums(string $key, TEnum> $enumClass)
        
    
    Retrieve data from the instance as an array of enums.
        
                    protected        bool
    isBackedEnum(class-string $enumClass)
        
    
    Determine if the given enum class is backed.
        
                            array
    array(array|string|null $key = null)
        
    
    Retrieve data from the instance as an array.
        
                            Collection
    collect(array|string|null $key = null)
        
    
    Retrieve data from the instance as a collection.
        
                            array
    only(mixed $keys)
        
    
    Get a subset containing the provided keys with values from the instance data.
        
                            array
    except(mixed $keys)
        
    
    Get all of the data except for a specified array of items.
        
                            string|array|null
    server(string|null $key = null, string|array|null $default = null)
        
    
    Retrieve a server variable from the request.
        
                            bool
    hasHeader(string $key)
        
    
    Determine if a header is set on the request.
        
                            string|array|null
    header(string|null $key = null, string|array|null $default = null)
        
    
    Retrieve a header from the request.
        
                            string|null
    bearerToken()
        
    
    Get the bearer token from the request headers.
        
                            array
    keys()
        
    
    Get the keys for all of the input and files.
        
                            mixed
    input(string|null $key = null, mixed $default = null)
        
    
    Retrieve an input item from the request.
        
                            Fluent
    fluent(array|string|null $key = null)
        
    
    Retrieve input from the request as a Fluent object instance.
        
                            string|array|null
    query(string|null $key = null, string|array|null $default = null)
        
    
    Retrieve a query string item from the request.
        
                            string|array|null
    post(string|null $key = null, string|array|null $default = null)
        
    
    Retrieve a request payload item from the request.
        
                            bool
    hasCookie(string $key)
        
    
    Determine if a cookie is set on the request.
        
                            string|array|null
    cookie(string|null $key = null, string|array|null $default = null)
        
    
    Retrieve a cookie from the request.
        
                            UploadedFile|UploadedFile[]>
    allFiles()
        
    
    Get an array of all of the files on the request.
        
                    protected        UploadedFile|UploadedFile[]>
    convertUploadedFiles(array $files)
        
    
    Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles.
        
                            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.
        
                            
    file(string|null $key = null, mixed $default = null)
        
    
    Retrieve a file from the request.
        
                    protected        string|array|null
    retrieveItem(string $source, string|null $key, string|array|null $default)
        
    
    Retrieve a parameter item from a given source.
        
                            $this|TWhenReturnType
    when($value = null, callable|null $callback = null, callable|null $default = null)
        
    
    Apply the callback if the given "value" is (or resolves to) truthy.
        
                            $this|TUnlessReturnType
    unless($value = null, callable|null $callback = null, callable|null $default = null)
        
    
    Apply the callback if the given "value" is (or resolves to) falsy.
        
                static            void
    macro(string $name, object|callable $macro)
        
    
    Register a custom macro.
        
                static            void
    mixin(object $mixin, bool $replace = true)
        
    
    Mix another object into the class.
        
                static            bool
    hasMacro(string $name)
        
    
    Checks if macro is registered.
        
                static            void
    flushMacros()
        
    
    Flush the existing macros.
        
                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.
        
                            Uri
    uri()
        
    
    Get a URI instance for the request.
        
                            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
    fullUrlWithoutQuery(array|string $keys)
        
    
    Get the full URL for the request without the given query string parameters.
        
                            string
    path()
        
    
    Get the current path info for the request.
        
                            string
    decodedPath()
        
    
    Get the current decoded 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(mixed ...$patterns)
        
    
    Determine if the current request URI matches a pattern.
        
                            bool
    routeIs(mixed ...$patterns)
        
    
    Determine if the route name matches a given pattern.
        
                            bool
    fullUrlIs(mixed ...$patterns)
        
    
    Determine if the current request URL and query string match a pattern.
        
                            string
    host()
        
    
    Get the host name.
        
                            string
    httpHost()
        
    
    Get the HTTP host being requested.
        
                            string
    schemeAndHttpHost()
        
    
    Get the scheme and HTTP host.
        
                            bool
    ajax()
        
    
    Determine if the request is the result of an AJAX call.
        
                            bool
    pjax()
        
    
    Determine if the request is the result of a PJAX call.
        
                            bool
    prefetch()
        
    
    Determine if the request is the result of a prefetch call.
        
                            bool
    secure()
        
    
    Determine if the request is over HTTPS.
        
                            string|null
    ip()
        
    
    Get the client IP address.
        
                            array
    ips()
        
    
    Get the client IP addresses.
        
                            string|null
    userAgent()
        
    
    Get the client user agent.
        
                            $this
    merge(array $input)
        
    
    Merge new input into the current request's input array.
        
                            $this
    mergeIfMissing(array $input)
        
    
    Merge new input into the request's input, but only when that key is missing from the request.
        
                            $this
    replace(array $input)
        
    
    Replace the input values for the current request.
        
                            mixed
    get(string $key, mixed $default = null)
        
    
    This method belongs to Symfony HttpFoundation and is not usually needed when using Laravel.
Instead, you may use the "input" method.
        
                            
    json(string|null $key = null, mixed $default = null)
        
    
    Get the JSON payload for the request.
        
                    protected        InputBag
    getInputSource()
        
    
    Get the input source for the request.
        
                static            Request
    createFrom(Request $from, Request|null $to = null)
        
    
    Create a new request instance from the given Laravel request.
        
                static            Request
    createFromBase(Request $request)
        
    
    Create an Illuminate request from a Symfony instance.
        
                            Request
    duplicate(array|null $query = null, array|null $request = null, array|null $attributes = null, array|null $cookies = null, array|null $files = null, array|null $server = null)
        
    
    {@inheritdoc}
        
                    protected        mixed
    filterFiles(mixed $files)
        
    
    Filter the given array of files, removing any empty values.
        
                            bool
    hasSession(bool $skipIfUninitialized = false)
        
    
    {@inheritdoc}
        
                            SessionInterface
    getSession()
        
    
    {@inheritdoc}
        
                            Session
    session()
        
    
    Get the session associated with the request.
        
                            void
    setLaravelSession(Session $session)
        
    
    Set the session instance on the request.
        
                            void
    setRequestLocale(string $locale)
        
    
    Set the locale for the request instance.
        
                            void
    setDefaultRequestLocale(string $locale)
        
    
    Set the default locale for the request instance.
        
                            mixed
    user(string|null $guard = null)
        
    
    Get the user making the request.
        
                            
    route(string|null $param = null, mixed $default = null)
        
    
    Get the route handling the request.
        
                            string
    fingerprint()
        
    
    Get a unique fingerprint for the request / route / IP address.
        
                            $this
    setJson(InputBag $json)
        
    
    Set the JSON payload for the request.
        
                            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.
        
                            
    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.
        
                            array
    validate(array $rules, mixed $params)
        
    
    No description
        
                            array
    validateWithBag(string $errorBag, array $rules, mixed $params)
        
    
    No description
        
                            bool
    hasValidSignature(bool $absolute = true)
        
    
    No description
        
                            bool
    hasValidRelativeSignature()
        
    
    No description
        
                            bool
    hasValidSignatureWhileIgnoring(mixed $ignoreQuery, mixed $absolute)
        
    
    No description
        
                            bool
    hasValidRelativeSignatureWhileIgnoring(mixed $ignoreQuery)
        
    
    No description
        
                            void
    validateResolved()
        
    
    Validate the class instance.
        
                    protected        void
    prepareForValidation()
        
    
    Prepare the data for validation.
        
                    protected        Validator
    getValidatorInstance()
        
    
    Get the validator instance for the request.
        
                    protected        void
    passedValidation()
        
    
    Handle a passed validation attempt.
        
                    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.
        
                            array
    validationData()
        
    
    Get data to be validated from the request.
        
                    protected        array
    validationRules()
        
    
    Get the validation rules for this form request.
        
                    protected        string
    getRedirectUrl()
        
    
    Get the URL to redirect to on a validation error.
        
                            ValidatedInput|array
    safe(array|null $keys = null)
        
    
    Get a validated input container for the validated input.
        
                            mixed
    validated(array|int|string|null $key = null, mixed $default = null)
        
    
    Get the validated data from the request.
        
                            array
    messages()
        
    
    Get custom messages for validator errors.
        
                            array
    attributes()
        
    
    Get custom attributes for validator errors.
        
                            $this
    setValidator(Validator $validator)
        
    
    Set the Validator instance.
        
                            $this
    setRedirector(Redirector $redirector)
        
    
    Set the Redirector instance.
        
                            $this
    setContainer(Container $container)
        
    
    Set the container implementation.