Sometimes you want to have a route that only accepts AJAX calls, or at least protect them if they are not AJAX calls.

Luckily Laravel has an easy helper in the Request class available for these type of things.

laravel ajax only middleware

This post is submitted by dennissmink.