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] Delay pushing jobs to queue until database transactions are committed #35422

Merged
merged 10 commits into from
Dec 9, 2020
Prev Previous commit
Next Next commit
include afterCommit and beforeCommit in PendingDispatch
  • Loading branch information
themsaid committed Nov 30, 2020
commit 4f76ee512f527c9a3313ab42cae3bd9da6825ce8
24 changes: 24 additions & 0 deletions src/Illuminate/Foundation/Bus/PendingDispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@ public function delay($delay)
return $this;
}

/**
* Indicate that the job should be dispatched after database transactions.
*
* @return $this
*/
public function afterCommit()
{
$this->job->afterCommit();

return $this;
}

/**
* Indicate that the job should be dispatched before database transactions.
*
* @return $this
*/
public function beforeCommit()
{
$this->job->beforeCommit();

return $this;
}

/**
* Set the jobs that should run if this job is successful.
*
Expand Down