Request
class Request extends Request implements Arrayable, ArrayAccess (View source)
Traits
InteractsWithContentTypes |
InteractsWithFlashData |
InteractsWithInput |
Macroable |
Properties
static protected array | $macros | The registered string macros. | from Macroable |
protected ParameterBag|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
static bool | matchesType(string $actual, string $type) Determine if the given content types match. | from InteractsWithContentTypes |
bool | isJson() Determine if the request is sending JSON. | from InteractsWithContentTypes |
bool | expectsJson() Determine if the current request probably expects a JSON response. | from InteractsWithContentTypes |
bool | wantsJson() Determine if the current request is asking for JSON. | from InteractsWithContentTypes |
bool | accepts(string|array $contentTypes) Determines whether the current requests accepts a given content type. | from InteractsWithContentTypes |
string|null | prefers(string|array $contentTypes) Return the most suitable content type from the given array based on content negotiation. | from InteractsWithContentTypes |
bool | acceptsAnyContentType() Determine if the current request accepts any content type. | from InteractsWithContentTypes |
bool | acceptsJson() Determines whether a request accepts JSON. | from InteractsWithContentTypes |
bool | acceptsHtml() Determines whether a request accepts HTML. | from InteractsWithContentTypes |
string | format(string $default = 'html') Get the data format expected in the response. | from InteractsWithContentTypes |
string|array | old(string $key = null, string|array|null $default = null) Retrieve an old input item. | from InteractsWithFlashData |
void | flash() Flash the input for the current request to the session. | from InteractsWithFlashData |
void | flashOnly(array|mixed $keys) Flash only some of the input to the session. | from InteractsWithFlashData |
void | flashExcept(array|mixed $keys) Flash only some of the input to the session. | from InteractsWithFlashData |
void | flush() Flush all of the old input from the session. | from InteractsWithFlashData |
string|array|null | server(string $key = null, string|array|null $default = null) Retrieve a server variable from the request. | from InteractsWithInput |
bool | hasHeader(string $key) Determine if a header is set on the request. | from InteractsWithInput |
string|array|null | header(string $key = null, string|array|null $default = null) Retrieve a header from the request. | from InteractsWithInput |
string|null | bearerToken() Get the bearer token from the request headers. | from InteractsWithInput |
bool | exists(string|array $key) Determine if the request contains a given input item key. | from InteractsWithInput |
bool | has(string|array $key) Determine if the request contains a given input item key. | from InteractsWithInput |
bool | hasAny(string|array $keys) Determine if the request contains any of the given inputs. | from InteractsWithInput |
bool | filled(string|array $key) Determine if the request contains a non-empty value for an input item. | from InteractsWithInput |
bool | anyFilled(string|array $keys) Determine if the request contains a non-empty value for any of the given inputs. | from InteractsWithInput |
bool | isEmptyString(string $key) Determine if the given input key is an empty string for "has". | from InteractsWithInput |
array | keys() Get the keys for all of the input and files. | from InteractsWithInput |
array | all(array|mixed $keys = null) Get all of the input and files for the request. | from InteractsWithInput |
string|array|null | input(string|null $key = null, string|array|null $default = null) Retrieve an input item from the request. | from InteractsWithInput |
array | only(array|mixed $keys) Get a subset containing the provided keys with values from the input data. | from InteractsWithInput |
array | except(array|mixed $keys) Get all of the input except for a specified array of items. | from InteractsWithInput |
string|array|null | query(string $key = null, string|array|null $default = null) Retrieve a query string item from the request. | from InteractsWithInput |
string|array|null | post(string $key = null, string|array|null $default = null) Retrieve a request payload item from the request. | from InteractsWithInput |
bool | hasCookie(string $key) Determine if a cookie is set on the request. | from InteractsWithInput |
string|array|null | cookie(string $key = null, string|array|null $default = null) Retrieve a cookie from the request. | from InteractsWithInput |
array | allFiles() Get an array of all of the files on the request. | from InteractsWithInput |
array | convertUploadedFiles(array $files) Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles. | from InteractsWithInput |
bool | hasFile(string $key) Determine if the uploaded data contains a file. | from InteractsWithInput |
bool | isValidFile(mixed $file) Check that the given file is a valid file instance. | from InteractsWithInput |
UploadedFile|array|null | file(string $key = null, mixed $default = null) Retrieve a file from the request. | from InteractsWithInput |
string|array|null | retrieveItem(string $source, string $key, string|array|null $default) Retrieve a parameter item from a given source. | from InteractsWithInput |
static void | macro(string $name, object|callable $macro) Register a custom macro. | from Macroable |
static void | mixin(object $mixin) Mix another object into the class. | 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. | |
$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 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(dynamic ...$patterns) Determine if the current request URI matches a pattern. | |
bool | routeIs(dynamic ...$patterns) Determine if the route name matches a given pattern. | |
bool | fullUrlIs(dynamic ...$patterns) 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() Get the client IP address. | |
array | ips() Get the client IP addresses. | |
string | userAgent() Get the client user agent. | |
Request | merge(array $input) Merge new input into the current request's input array. | |
Request | 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. | |
ParameterBag|mixed | json(string $key = null, mixed $default = null) Get the JSON payload for the request. | |
ParameterBag | 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. | |
duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) {@inheritdoc} | ||
mixed | filterFiles(mixed $files) Filter the given array of files, removing any empty values. | |
Store | session() Get the session associated with the request. | |
Store|null | getSession() Get the session associated with the request. | |
void | setLaravelSession(Session $session) Set the session instance on the request. | |
mixed | user(string|null $guard = null) Get the user making the request. | |
Route|object|string | 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(ParameterBag $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. | |
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. |
Details
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.
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.
string format(string $default = 'html')
Get the data format expected in the response.
string|array old(string $key = null, 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 $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 $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.
bool filled(string|array $key)
Determine if the request contains a non-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.
protected bool isEmptyString(string $key)
Determine if the given input key is an empty string for "has".
array keys()
Get the keys for all of the input and files.
array all(array|mixed $keys = null)
Get all of the input and files for the request.
string|array|null input(string|null $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.
string|array|null query(string $key = null, string|array|null $default = null)
Retrieve a query string item from the request.
string|array|null post(string $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 $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|array|null file(string $key = null, mixed $default = null)
Retrieve a file from the request.
protected string|array|null retrieveItem(string $source, string $key, string|array|null $default)
Retrieve a parameter item from a given source.
static void macro(string $name, object|callable $macro)
Register a custom macro.
static void mixin(object $mixin)
Mix another object into the class.
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 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(dynamic ...$patterns)
Determine if the current request URI matches a pattern.
bool routeIs(dynamic ...$patterns)
Determine if the route name matches a given pattern.
bool fullUrlIs(dynamic ...$patterns)
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()
Get the client IP address.
array ips()
Get the client IP addresses.
string userAgent()
Get the client user agent.
Request merge(array $input)
Merge new input into the current request's input array.
Request 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.
ParameterBag|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 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.
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.
Store|null getSession()
Get the session associated with the request.
void setLaravelSession(Session $session)
Set the session instance on the request.
mixed user(string|null $guard = null)
Get the user making the request.
Route|object|string 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(ParameterBag $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.
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.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.7/Illuminate/Http/Request.html