Request
class Request extends Request implements Arrayable, ArrayAccess (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected InputBag|null | $json | The decoded JSON content for the request. |
|
protected array | $convertedFiles | All of the converted files for the request. |
|
protected Closure | $userResolver | The user resolver callback. |
|
protected Closure | $routeResolver | The route resolver callback. |
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 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 given input item key.
Determine if the request contains any of the given inputs.
Apply the callback if the request contains the given input item key.
Determine if the request contains a non-empty value for an input item.
Determine if the request contains an empty value for an input item.
Determine if the request contains a non-empty value for any of the given inputs.
Apply the callback if the request contains a non-empty value for the given input item key.
Determine if the request is missing a given input item key.
Apply the callback if the request is missing the given input item key.
Determine if the given input key is an empty string for "filled".
Get all of the input and files for the request.
Retrieve an input item from the request.
Retrieve input from the request as a Stringable instance.
Retrieve input from the request as a Stringable instance.
Retrieve input as a boolean value.
Retrieve input as an integer value.
Retrieve input as a float value.
Retrieve input from the request as a Carbon instance.
Retrieve input from the request as an enum.
Retrieve input from the request as a collection.
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.
Retrieve a query string item from the request.
Retrieve a request payload 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.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Return the Request instance.
Get the request method.
Get the root URL for the application.
Get the URL (no query string) for the request.
Get the full URL for the request.
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 the current path info for the request.
Get the current decoded path info for the request.
Get a segment from the URI (1 based index).
Get all of the segments for the request path.
Determine if the current request URI matches a pattern.
Determine if the route name matches a given pattern.
Determine if the current request URL and query string match a pattern.
Get the host name.
Get the HTTP host being requested.
Get the scheme and HTTP host.
Determine if the request is the result of an AJAX call.
Determine if the request is the result of a PJAX call.
Determine if the request is the result of a prefetch call.
Determine if the request is over HTTPS.
Get the client IP address.
Get the client IP addresses.
Get the client user agent.
Merge new input into the current request's input array.
Merge new input into the request's input, but only when that key is missing from the request.
Replace the input for the current request.
This method belongs to Symfony HttpFoundation and is not usually needed when using Laravel.
Get the JSON payload for the request.
Get the input source 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.
{@inheritdoc}
{@inheritdoc}
Set the locale for the request instance.
Set the default locale for the request instance.
Get the user making the request.
Get the route handling the request.
Get a unique fingerprint for the request / route / IP address.
Set the JSON payload for the request.
Get the user resolver callback.
Get the route resolver callback.
Get all of the input and files for the request.
Determine if the given offset exists.
Get the value at the given offset.
Set the value at the given offset.
Remove the value at the given offset.
Check if an input element is set on the request.
Get an input element from the request.
No description
No description
No description
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(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.
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.
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 given input item key.
bool
hasAny(string|array $keys)
Determine if the request contains any of the given inputs.
$this|mixed
whenHas(string $key, callable $callback, callable $default = null)
Apply the callback if the request contains the given input item key.
bool
filled(string|array $key)
Determine if the request contains a non-empty value for an input item.
bool
isNotFilled(string|array $key)
Determine if the request contains an empty value for an input item.
bool
anyFilled(string|array $keys)
Determine if the request contains a non-empty value for any of the given inputs.
$this|mixed
whenFilled(string $key, callable $callback, callable $default = null)
Apply the callback if the request contains a non-empty value for the given input item key.
bool
missing(string|array $key)
Determine if the request is missing a given input item key.
$this|mixed
whenMissing(string $key, callable $callback, callable $default = null)
Apply the callback if the request is missing the given input item key.
protected bool
isEmptyString(string $key)
Determine if the given input key is an empty string for "filled".
array
keys()
Get the keys for all of the input and files.
array
all(array|mixed|null $keys = null)
Get all of the input and files for the request.
mixed
input(string|null $key = null, mixed $default = null)
Retrieve an input item from the request.
Stringable
str(string $key, mixed $default = null)
Retrieve input from the request as a Stringable instance.
Stringable
string(string $key, mixed $default = null)
Retrieve input from the request as a Stringable instance.
bool
boolean(string|null $key = null, bool $default = false)
Retrieve input 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 input as an integer value.
float
float(string $key, float $default = 0.0)
Retrieve input as a float value.
Carbon|null
date(string $key, string|null $format = null, string|null $tz = null)
Retrieve input from the request as a Carbon instance.
TEnum|null
enum(string $key, TEnum> $enumClass)
Retrieve input from the request as an enum.
Collection
collect(array|string|null $key = null)
Retrieve input from the request as a collection.
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.
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.
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.
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.
UploadedFile|UploadedFile[]|array|null
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.
never
dd(mixed ...$keys)
Dump the request items and end the script.
$this
dump(mixed $keys = [])
Dump the items.
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.
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 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.
InputBag|mixed
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 $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.
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|object|string|null
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