trait InteractsWithContentTypes

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.

Details

at line 16
static bool matchesType(string $actual, string $type)

Determine if the given content types match.

Parameters

string $actual
string $type

Return Value

bool

at line 32
bool isJson()

Determine if the request is sending JSON.

Return Value

bool

at line 42
bool expectsJson()

Determine if the current request probably expects a JSON response.

Return Value

bool

at line 52
bool wantsJson()

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

Return Value

bool

at line 65
bool accepts(string|array $contentTypes)

Determines whether the current requests accepts a given content type.

Parameters

string|array $contentTypes

Return Value

bool

at line 96
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

at line 126
bool acceptsJson()

Determines whether a request accepts JSON.

Return Value

bool

at line 136
bool acceptsHtml()

Determines whether a request accepts HTML.

Return Value

bool

at line 147
string format(string $default = 'html')

Get the data format expected in the response.

Parameters

string $default

Return Value

string