public function apply(callable $transform): self
    {
        $result = $transform($this) ?? $this;

        if ($result instanceof self) {
            return $result;
        }

        return $this->handleException(InvalidReturnValueException::create(
            'The transform function return value',
            $result,
            ['null', self::class]
        ));
    }
public function apply(callable $transform): self
    {
        $result = $transform($this) ?? $this;

        if ($result instanceof self) {
            return $result;
        }

        return $this->handleException(InvalidReturnValueException::create(
            'The transform function return value',
            $result,
            ['null', self::class]
        ));
    }
public function apply ( callable $ transform ) : self { $ result = $ transform ( $ this ) ?? $ this ; if ( $ result instanceof self ) { return $ result ; } return $ this -> handleException ( InvalidReturnValueException :: create ( 'The transform function return value' , $ result , [ 'null' , self :: class ] ) ) ; }
Modifies this query by passing it through a transform function.

Warning! In contrast to the other methods, this method can both change this object and return a new object. The
returned query is the only query guaranteed to be a proper result query.

@param callable $transform The function. It recieves this query object as the first argument. It must either
change the given object or return a new query object.
@return static Result query object
@throws InvalidReturnValueException If the callback return value is wrong
Modifies this query by passing it through a transform function .