src/Concerns/HasMiddleware.php
protected function groupMiddleware(string $name = null, Closure $closure = null)
    {
        if ($name === null) {
            return $this->middlewareGroupId;
        } else {
            $previousGroup = $this->middlewareGroupId;
            $this->middlewareGroupId = $name;
            if ($closure !== null) {
                $closure($this);
                $this->middlewareGroupId = $previousGroup;
            }
            return $this;
        }
    }
protected function groupMiddleware(string $name = null, Closure $closure = null)
    {
        if ($name === null) {
            return $this->middlewareGroupId;
        } else {
            $previousGroup = $this->middlewareGroupId;
            $this->middlewareGroupId = $name;
            if ($closure !== null) {
                $closure($this);
                $this->middlewareGroupId = $previousGroup;
            }
            return $this;
        }
    }
Define the default group setting.

@param string|null $name
@param \Closure|null $closure
@return string|$this