[13.x] Document insertBefore and insertAfter middleware methods

Merged
RA
8d ago
+29-0

laravel/framework#62261 added insertBefore(), insertAfter(), insertBeforeInGroup() and insertAfterInGroup() to the middleware configuration, but middleware.md only covers append/prepend and the group helpers.

This adds a short example to Global Middleware and one to Laravel's Default Middleware Groups. It also notes that you can pass an array, and that nothing gets inserted when the target middleware isn't in the stack. That second point is easy to trip over with TrustHosts, which isn't in the default stack unless you call trustHosts().

I checked the resulting order with getGlobalMiddleware() / getMiddlewareGroups() on 13.x, and after route middleware priority sorting for the group example.