Request

class Request implements ArrayAccess (View source)

Properties

protected RequestInterface $request The underlying PSR request.
protected array $data The decoded payload for the request.

Methods

void __construct(RequestInterface $request)

Create a new request instance.

string method()

Get the request method.

string url()

Get the URL of the request.

bool hasHeader(string $key, mixed $value = null)

Determine if the request has a given header.

bool hasHeaders(array|string $headers)

Determine if the request has the given headers.

array header(string $key)

Get the values for the header with the given name.

array headers()

Get the request headers.

string body()

Get the body of the request.

bool hasFile(string $name, string|null $value = null, string|null $filename = null)

Determine if the request contains the given file.

array data()

Get the request's data (form parameters or JSON).

array parameters()

Get the request's form parameters.

array json()

Get the JSON decoded body of the request.

bool isForm()

Determine if the request is simple form data.

bool isJson()

Determine if the request is JSON.

bool isMultipart()

Determine if the request is multipart.

$this withData(array $data)

Set the decoded data on the request.

RequestInterface toPsrRequest()

Get the underlying PSR compliant request instance.

bool offsetExists(string $offset)

Determine if the given offset exists.

mixed offsetGet(string $offset)

Get the value for a given offset.

void offsetSet(string $offset, mixed $value)

Set the value at the given offset.

void offsetUnset(string $offset)

Unset the value at the given offset.

Details

void __construct(RequestInterface $request)

Create a new request instance.

Parameters

RequestInterface $request

Return Value

void

string method()

Get the request method.

Return Value

string

string url()

Get the URL of the request.

Return Value

string

bool hasHeader(string $key, mixed $value = null)

Determine if the request has a given header.

Parameters

string $key
mixed $value

Return Value

bool

bool hasHeaders(array|string $headers)

Determine if the request has the given headers.

Parameters

array|string $headers

Return Value

bool

array header(string $key)

Get the values for the header with the given name.

Parameters

string $key

Return Value

array

array headers()

Get the request headers.

Return Value

array

string body()

Get the body of the request.

Return Value

string

bool hasFile(string $name, string|null $value = null, string|null $filename = null)

Determine if the request contains the given file.

Parameters

string $name
string|null $value
string|null $filename

Return Value

bool

array data()

Get the request's data (form parameters or JSON).

Return Value

array

protected array parameters()

Get the request's form parameters.

Return Value

array

protected array json()

Get the JSON decoded body of the request.

Return Value

array

bool isForm()

Determine if the request is simple form data.

Return Value

bool

bool isJson()

Determine if the request is JSON.

Return Value

bool

bool isMultipart()

Determine if the request is multipart.

Return Value

bool

$this withData(array $data)

Set the decoded data on the request.

Parameters

array $data

Return Value

$this

RequestInterface toPsrRequest()

Get the underlying PSR compliant request instance.

Return Value

RequestInterface

bool offsetExists(string $offset)

Determine if the given offset exists.

Parameters

string $offset

Return Value

bool

mixed offsetGet(string $offset)

Get the value for a given offset.

Parameters

string $offset

Return Value

mixed

void offsetSet(string $offset, mixed $value)

Set the value at the given offset.

Parameters

string $offset
mixed $value

Return Value

void

Exceptions

LogicException

void offsetUnset(string $offset)

Unset the value at the given offset.

Parameters

string $offset

Return Value

void

Exceptions

LogicException

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/7.x/Illuminate/Http/Client/Request.html