trait InteractsWithContentTypes (View source)

Methods

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.

static bool
matchesType(string $actual, string $type)

Determine if the given content types match.

string
format(string $default = 'html')

Get the data format expected in the response.

Details

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.

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 acceptsAnyContentType()

Determine if the current request accepts any content type.

Return Value

bool

bool acceptsJson()

Determines whether a request accepts JSON.

Return Value

bool

bool acceptsHtml()

Determines whether a request accepts HTML.

Return Value

bool

static bool matchesType(string $actual, string $type)

Determine if the given content types match.

Parameters

string $actual
string $type

Return Value

bool

string format(string $default = 'html')

Get the data format expected in the response.

Parameters

string $default

Return Value

string