Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Add delay() to PendingChain #34789

Merged
merged 1 commit into from Oct 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Illuminate/Foundation/Bus/PendingChain.php
Expand Up @@ -37,6 +37,13 @@ class PendingChain
*/
public $queue;

/**
* The number of seconds before the chain should be made available.
*
* @var \DateTimeInterface|\DateInterval|int|null
*/
public $delay;

/**
* The callbacks to be executed on failure.
*
Expand Down Expand Up @@ -83,6 +90,19 @@ public function onQueue($queue)
return $this;
}

/**
* Set the desired delay for the chain.
*
* @param \DateTimeInterface|\DateInterval|int|null $delay
* @return $this
*/
public function delay($delay)
{
$this->delay = $delay;

return $this;
}

/**
* Add a callback to be executed on job failure.
*
Expand Down Expand Up @@ -126,6 +146,7 @@ public function dispatch()
$firstJob->allOnConnection($this->connection);
$firstJob->allOnQueue($this->queue);
$firstJob->chain($this->chain);
$firstJob->delay($this->delay);
$firstJob->chainCatchCallbacks = $this->catchCallbacks();

return app(Dispatcher::class)->dispatch($firstJob);
Expand Down