ApiRequest
class ApiRequest extends Request
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected array | $data | The decoded payload for the request. |
from Request |
| protected array | $attributes | The attribute data passed when building the PendingRequest. |
from Request |
| protected array | $context | from HasContext | |
| protected bool | $dataChanged | Determine if the request data has changed. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Determine if the request has a given header.
Determine if the request contains the given file.
Get the underlying PSR compliant request instance.
Set the API request/response context.
Set the request method.
Set the request URL.
Add the request header.
Add the request headers.
Specify the request's content type.
Indicate the request contains form parameters.
Indicate the request contains JSON.
Indicate that JSON should be returned by the server.
Indicate the type of content that should be returned by the server.
Specify an authorization token for the request.
Specify the user agent for the request.
Add a request header.
Add request headers.
Remove a request header.
Remove request headers.
Set the request body.
Remove the request data.
No description
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
in
Request at line 32
__construct(RequestInterface $request)
Create a new request instance.
in
Request at line 39
string
method()
Get the request method.
in
Request at line 47
string
url()
Get the URL of the request.
in
Request at line 63
bool
hasHeader(string $key, mixed $value = null)
Determine if the request has a given header.
in
Request at line 83
bool
hasHeaders(array|string $headers)
Determine if the request has the given headers.
in
Request at line 101
array
header(string $key)
Get the values for the header with the given name.
in
Request at line 109
array
headers()
Get the request headers.
in
Request at line 117
string
body()
Get the body of the request.
in
Request at line 125
bool
hasFile(string $name, string|null $value = null, string|null $filename = null)
Determine if the request contains the given file.
in
Request at line 141
array
data()
Get the request's data (form parameters or JSON).
in
Request at line 156
protected array
parameters()
Get the request's form parameters.
in
Request at line 170
protected array
json()
Get the JSON decoded body of the request.
in
Request at line 182
bool
isForm()
Determine if the request is simple form data.
in
Request at line 190
bool
isJson()
Determine if the request is JSON.
in
Request at line 199
bool
isMultipart()
Determine if the request is multipart.
at line 193
Request
withData(array $data)
Add the request data.
in
Request at line 215
array
query()
No description
in
Request at line 245
array
attributes()
Get the attribute data from the request.
in
Request at line 253
Request
setRequestAttributes(array $attributes)
Set the request's attribute data.
at line 217
RequestInterface
toPsrRequest()
Get the underlying PSR compliant request instance.
in
Request at line 273
bool
offsetExists(string $offset)
Determine if the given offset exists.
in
Request at line 283
mixed
offsetGet(string $offset)
Get the value for a given offset.
in
Request at line 295
void
offsetSet(string $offset, mixed $value)
Set the value at the given offset.
in
Request at line 307
void
offsetUnset(string $offset)
Unset the value at the given offset.
in
Request at line 315
static void
flushState()
Flush all static state.
in
HasContext at line 14
HasContext
withContext(string|array $key, mixed $value = null)
Set the API request/response context.
in
HasContext at line 30
mixed
context(string|null $key = null)
Get the API request/response context.
at line 24
ApiRequest
withMethod(string $method)
Set the request method.
at line 34
ApiRequest
withUrl(callable|string $url, bool $preserveHost = false)
Set the request URL.
at line 48
ApiRequest
withHeader(string $key, string $value)
Add the request header.
at line 56
ApiRequest
withHeaders(array $headers)
Add the request headers.
at line 68
ApiRequest
contentType(string $contentType)
Specify the request's content type.
at line 78
ApiRequest
asForm()
Indicate the request contains form parameters.
at line 94
ApiRequest
asJson()
Indicate the request contains JSON.
at line 110
ApiRequest
acceptJson()
Indicate that JSON should be returned by the server.
at line 118
ApiRequest
accept(string $contentType)
Indicate the type of content that should be returned by the server.
at line 126
ApiRequest
withToken(string $token, string $type = 'Bearer')
Specify an authorization token for the request.
at line 134
ApiRequest
withUserAgent(bool|string $userAgent)
Specify the user agent for the request.
at line 142
ApiRequest
withAddedHeader(string $key, string $value)
Add a request header.
at line 150
ApiRequest
withAddedHeaders(array $headers)
Add request headers.
at line 162
ApiRequest
withoutHeader(string $header)
Remove a request header.
at line 170
ApiRequest
withoutHeaders(array $headers)
Remove request headers.
at line 182
ApiRequest
withBody(string $body)
Set the request body.
at line 204
ApiRequest
withoutData(array $data)
Remove the request data.
at line 226
protected void
applyChangedData()
No description