public function chunk(int $size, callable $callback)
    {
        if ($size <= 0) {
            $this->handleException(new InvalidArgumentException('Chunk size must be greater than zero'));
        }

        // A copy is made not to mutate this query
        $query = clone $this;

        for ($offset = 0;; $offset += $size) {
            $rows = $query->offset($offset)->limit($size)->get();
            if (empty($rows)) {
                break;
            }

            $callback($rows);

            if (count($rows) < $size) {
                break;
            }
        }
    }