src/Concerns/HasMiddleware.php
protected function setMiddlewareContext($context, MiddlewareCollection &$group = null)
    {
        if ($group === null) {
            $group = $this->middleware;
        }
        if ($group) {
            foreach ($group as &$value) {
                if ($value instanceof MiddlewareCollection) {
                    $this->setMiddlewareContext($context, $value);
                } elseif ($value instanceof MiddlewareInterface) {
                    $value->as($context);
                }
            }
        }
        return $this;
    }
protected function setMiddlewareContext($context, MiddlewareCollection &$group = null)
    {
        if ($group === null) {
            $group = $this->middleware;
        }
        if ($group) {
            foreach ($group as &$value) {
                if ($value instanceof MiddlewareCollection) {
                    $this->setMiddlewareContext($context, $value);
                } elseif ($value instanceof MiddlewareInterface) {
                    $value->as($context);
                }
            }
        }
        return $this;
    }
Sets the context for the middleware.

@param $context
@param \MichaelRShelton\MiddleMan\Interfaces\MiddlewareCollection|null $group
@return $this