class Request extends Request implements Arrayable, ArrayAccess (View source)

Traits

Methods

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|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
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
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 non-empty value for an input item.

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.

bool
hasFile(string $key)

Determine if the uploaded data contains a file.

UploadedFile|array|null
file(string $key = null, mixed $default = null)

Retrieve a file from the request.

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.

$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
routeIs(string $name)

Check if the route name matches the given string.

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.

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.

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)

[email protected]}

session()

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)

Get the route handling the request.

string
fingerprint()

Get a unique fingerprint for the request / route / IP address.

$this
setJson(array $json)

Set the JSON payload for the request.

getUserResolver()

Get the user resolver callback.

$this
setUserResolver(Closure $callback)

Set the user resolver callback.

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.

Parameters

string $actual
string $type

Return Value

bool

bool isJson()

Determine if the request is sending JSON.

Return Value

bool

bool expectsJson()

Determine if the current request probably expects a JSON response.

Return Value

bool

bool wantsJson()

Determine if the current request is asking for JSON in return.

Return Value

bool

bool accepts(string|array $contentTypes)

Determines whether the current requests accepts a given content type.

Parameters

string|array $contentTypes

Return Value

bool

string|null prefers(string|array $contentTypes)

Return the most suitable content type from the given array based on content negotiation.

Parameters

string|array $contentTypes

Return Value

string|null

bool acceptsJson()

Determines whether a request accepts JSON.

Return Value

bool

bool acceptsHtml()

Determines whether a request accepts HTML.

Return Value

bool

string format(string $default = 'html')

Get the data format expected in the response.

Parameters

string $default

Return Value

string

string|array old(string $key = null, string|array|null $default = null)

Retrieve an old input item.

Parameters

string $key
string|array|null $default

Return Value

string|array

void flash()

Flash the input for the current request to the session.

Return Value

void

void flashOnly(array|mixed $keys)

Flash only some of the input to the session.

Parameters

array|mixed $keys

Return Value

void

void flashExcept(array|mixed $keys)

Flash only some of the input to the session.

Parameters

array|mixed $keys

Return Value

void

void flush()

Flush all of the old input from the session.

Return Value

void

string|array server(string $key = null, string|array|null $default = null)

Retrieve a server variable from the request.

Parameters

string $key
string|array|null $default

Return Value

string|array

bool hasHeader(string $key)

Determine if a header is set on the request.

Parameters

string $key

Return Value

bool

string|array header(string $key = null, string|array|null $default = null)

Retrieve a header from the request.

Parameters

string $key
string|array|null $default

Return Value

string|array

string|null bearerToken()

Get the bearer token from the request headers.

Return Value

string|null

bool exists(string|array $key)

Determine if the request contains a given input item key.

Parameters

string|array $key

Return Value

bool

bool has(string|array $key)

Determine if the request contains a non-empty value for an input item.

Parameters

string|array $key

Return Value

bool

array all()

Get all of the input and files for the request.

Return Value

array

string|array input(string $key = null, string|array|null $default = null)

Retrieve an input item from the request.

Parameters

string $key
string|array|null $default

Return Value

string|array

array only(array|mixed $keys)

Get a subset containing the provided keys with values from the input data.

Parameters

array|mixed $keys

Return Value

array

array except(array|mixed $keys)

Get all of the input except for a specified array of items.

Parameters

array|mixed $keys

Return Value

array

array intersect(array|mixed $keys)

Intersect an array of items with the input data.

Parameters

array|mixed $keys

Return Value

array

string|array query(string $key = null, string|array|null $default = null)

Retrieve a query string item from the request.

Parameters

string $key
string|array|null $default

Return Value

string|array

bool hasCookie(string $key)

Determine if a cookie is set on the request.

Parameters

string $key

Return Value

bool

Retrieve a cookie from the request.

Parameters

string $key
string|array|null $default

Return Value

string|array

array allFiles()

Get an array of all of the files on the request.

Return Value

array

bool hasFile(string $key)

Determine if the uploaded data contains a file.

Parameters

string $key

Return Value

bool

UploadedFile|array|null file(string $key = null, mixed $default = null)

Retrieve a file from the request.

Parameters

string $key
mixed $default

Return Value

UploadedFile|array|null

in Macroable at line line 24
static void macro(string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

in Macroable at line line 35
static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line line 49
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line line 71
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line line 55
static Request capture()

Create a new Illuminate HTTP request from server variables.

Return Value

Request

at line line 67
$this instance()

Return the Request instance.

Return Value

$this

at line line 77
string method()

Get the request method.

Return Value

string

at line line 87
string root()

Get the root URL for the application.

Return Value

string

at line line 97
string url()

Get the URL (no query string) for the request.

Return Value

string

at line line 107
string fullUrl()

Get the full URL for the request.

Return Value

string

at line line 122
string fullUrlWithQuery(array $query)

Get the full URL for the request with the added query string parameters.

Parameters

array $query

Return Value

string

at line line 136
string path()

Get the current path info for the request.

Return Value

string

at line line 148
string decodedPath()

Get the current encoded path info for the request.

Return Value

string

at line line 160
string|null segment(int $index, string|null $default = null)

Get a segment from the URI (1 based index).

Parameters

int $index
string|null $default

Return Value

string|null

at line line 170
array segments()

Get all of the segments for the request path.

Return Value

array

at line line 184
bool is()

Determine if the current request URI matches a pattern.

Return Value

bool

at line line 201
bool routeIs(string $name)

Check if the route name matches the given string.

Parameters

string $name

Return Value

bool

at line line 211
bool fullUrlIs()

Determine if the current request URL and query string matches a pattern.

Return Value

bool

at line line 229
bool ajax()

Determine if the request is the result of an AJAX call.

Return Value

bool

at line line 239
bool pjax()

Determine if the request is the result of an PJAX call.

Return Value

bool

at line line 249
bool secure()

Determine if the request is over HTTPS.

Return Value

bool

at line line 259
string ip()

Returns the client IP address.

Return Value

string

at line line 269
array ips()

Returns the client IP addresses.

Return Value

array

at line line 280
void merge(array $input)

Merge new input into the current request's input array.

Parameters

array $input

Return Value

void

at line line 291
void replace(array $input)

Replace the input for the current request.

Parameters

array $input

Return Value

void

at line line 303
mixed json(string $key = null, mixed $default = null)

Get the JSON payload for the request.

Parameters

string $key
mixed $default

Return Value

mixed

at line line 336
static Request createFromBase(Request $request)

Create an Illuminate request from a Symfony instance.

Parameters

Request $request

Return Value

Request

at line line 359
duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)

[email protected]}

Parameters

array $query
array $request
array $attributes
array $cookies
array $files
array $server

at line line 396
Store session()

Get the session associated with the request.

Return Value

Store

Exceptions

RuntimeException

at line line 411
void setLaravelSession(Session $session)

Set the session instance on the request.

Parameters

Session $session

Return Value

void

at line line 422
mixed user(string|null $guard = null)

Get the user making the request.

Parameters

string|null $guard

Return Value

mixed

at line line 434
Route|object|string route(string|null $param = null)

Get the route handling the request.

Parameters

string|null $param

Return Value

Route|object|string

at line line 452
string fingerprint()

Get a unique fingerprint for the request / route / IP address.

Return Value

string

Exceptions

RuntimeException

at line line 469
$this setJson(array $json)

Set the JSON payload for the request.

Parameters

array $json

Return Value

$this

at line line 481
Closure getUserResolver()

Get the user resolver callback.

Return Value

Closure

at line line 494
$this setUserResolver(Closure $callback)

Set the user resolver callback.

Parameters

Closure $callback

Return Value

$this

at line line 506
Closure getRouteResolver()

Get the route resolver callback.

Return Value

Closure

at line line 519
$this setRouteResolver(Closure $callback)

Set the route resolver callback.

Parameters

Closure $callback

Return Value

$this

at line line 531
array toArray()

Get all of the input and files for the request.

Return Value

array

at line line 542
bool offsetExists(string $offset)

Determine if the given offset exists.

Parameters

string $offset

Return Value

bool

at line line 553
mixed offsetGet(string $offset)

Get the value at the given offset.

Parameters

string $offset

Return Value

mixed

at line line 565
void offsetSet(string $offset, mixed $value)

Set the value at the given offset.

Parameters

string $offset
mixed $value

Return Value

void

at line line 576
void offsetUnset(string $offset)

Remove the value at the given offset.

Parameters

string $offset

Return Value

void

at line line 587
bool __isset(string $key)

Check if an input element is set on the request.

Parameters

string $key

Return Value

bool

at line line 598
mixed __get(string $key)

Get an input element from the request.

Parameters

string $key

Return Value

mixed