Skip to content

[9.x] Allows object instead of array when adding to PendingBatch#41475

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
yoeriboven:batch-add
Mar 16, 2022
Merged

[9.x] Allows object instead of array when adding to PendingBatch#41475
taylorotwell merged 1 commit into
laravel:9.xfrom
yoeriboven:batch-add

Conversation

@yoeriboven

Copy link
Copy Markdown
Contributor

Currently you need to pass an array when you want to add to a batch.

$batch = Bus::batch([]);
$batch->add([new Job]);
$batch->dispatch();

With this PR you can do this:

$batch = Bus::batch([]);
$batch->add(new Job);
$batch->dispatch();

This is already possible if you want to add to an already dispatched batch:

$this->batch()->add(new Job);

The add function on PendingBatch wasn't tested yet either so I added a test.

Comment thread src/Illuminate/Bus/PendingBatch.php
@GrahamCampbell GrahamCampbell marked this pull request as draft March 14, 2022 15:17
@yoeriboven yoeriboven marked this pull request as ready for review March 16, 2022 14:44
@taylorotwell taylorotwell merged commit d10ab79 into laravel:9.x Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants