src/RouteCollector.php
public function addGroup($prefix, array $middleware, callable $callback)
    {
        $previousMiddlewareStack = $this->middlewareStack;
        $previousGroupPrefix = $this->currentGroupPrefix;
        $this->currentGroupPrefix = $previousGroupPrefix . $prefix;
        $this->middlewareStack = array_merge($previousMiddlewareStack, $middleware);
        $callback($this);
        $this->currentGroupPrefix = $previousGroupPrefix;
        $this->middlewareStack = $previousMiddlewareStack;
    }
public function addGroup($prefix, array $middleware, callable $callback)
    {
        $previousMiddlewareStack = $this->middlewareStack;
        $previousGroupPrefix = $this->currentGroupPrefix;
        $this->currentGroupPrefix = $previousGroupPrefix . $prefix;
        $this->middlewareStack = array_merge($previousMiddlewareStack, $middleware);
        $callback($this);
        $this->currentGroupPrefix = $previousGroupPrefix;
        $this->middlewareStack = $previousMiddlewareStack;
    }
Create a route group with a common prefix.

All routes created in the passed callback will have the given group prefix prepended.

@param string              $prefix      String to be prepended to this route
@param Middleware|string[] $middleware  Middleware to be added to all routes in this group
@param callable            $callback    Definition callback