trait InteractsWithContentTypes

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

Determine if the current request is asking for Markdown.

bool
accepts(string|array $contentTypes)

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

Determine whether a request accepts JSON.

bool
acceptsMarkdown()

Determine whether a request accepts Markdown.

bool
acceptsHtml()

Determine 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

at line 14
bool isJson()

Determine if the request is sending JSON.

Return Value

bool

at line 22
bool expectsJson()

Determine if the current request probably expects a JSON response.

Return Value

bool

at line 30
bool wantsJson()

Determine if the current request is asking for JSON.

Return Value

bool

at line 40
bool wantsMarkdown()

Determine if the current request is asking for Markdown.

Return Value

bool

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

Determine whether the current requests accepts a given content type.

Parameters

string|array $contentTypes

Return Value

bool

at line 86
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 124
bool acceptsAnyContentType()

Determine if the current request accepts any content type.

Return Value

bool

at line 136
bool acceptsJson()

Determine whether a request accepts JSON.

Return Value

bool

at line 144
bool acceptsMarkdown()

Determine whether a request accepts Markdown.

Return Value

bool

at line 152
bool acceptsHtml()

Determine whether a request accepts HTML.

Return Value

bool

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

Determine if the given content types match.

Parameters

string $actual
string $type

Return Value

bool

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

Get the data format expected in the response.

Parameters

string $default

Return Value

string