Laravel Auth system has a lot of features, but it doesn’t include suspending users for some time, like banning some angry forum user for 14 days to calm down. Luckily, it’s easy to implement, with Middleware. This article will show you how.
Sometimes you want to have a route that only accepts AJAX calls, or at least protect them if they are not AJAX calls.
I’ve always tested middleware in one of two ways, a unit test with mocks and asserting the callback in the handle method or integration tests on application routes.