Chris Fidao has a quick post to his site looking at content negotiation in Laravel apps using some of the framework's own built-in functionality.
Here's a little bit about content negotiation. An HTTP client, such as your browser, or perhaps jQuery's ajax method, can set an Accept header as part of an HTTP request. [...] This header is meant to tell the server what content types it is willing to accept.
He starts with a bit of illustration as to what the
Accept header is and what kinds of values it supports (and how it looks as a HTTP header). He then shows how to check the
Accept header value inside the current request. He also shows the "shortcut" Laravel provides to test if the
Accept header specifically references JSON with the
wantsJson method. He also mentions the accepts and prefers methods for checks that need to be a bit more in-depth.