src/Concerns/HasMiddleware.php
protected function thenCallMiddleware($middleware)
    {
        if (function_exists('call_middleware')) {
            $this->result = call_middleware($middleware, $this->result);
        } else {
            $this->result = (new Caller($middleware))->call($this->result);
        }
        return $this->resultUnlessChainable();
    }
protected function thenCallMiddleware($middleware)
    {
        if (function_exists('call_middleware')) {
            $this->result = call_middleware($middleware, $this->result);
        } else {
            $this->result = (new Caller($middleware))->call($this->result);
        }
        return $this->resultUnlessChainable();
    }
Calls the given middleware and returns the result as if part of the middleware chains.

The helper function will check for an app container, which can assist in injecting dependencies.

@param mixed $middleware
@return \MichaelRShelton\MiddleMan\Controller|mixed