Skip to content

Batch Jobs: how to know you're in last batch? #13878

Closed Answered by brandonkelly
janhenckens asked this question in Q&A
Discussion options

You must be logged in to vote

You could do this by overriding the execute() function like so:

public function execute($queue): void
{
    parent::execute($queue);

    // Was this the last batch?
    if ($this->itemOffset >= $this->totalItems()) {
        // ...
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@janhenckens
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants