therezor/laravel-transactional-jobs

Submit laravel jobs inside transaction. Cancel job after rollback. Proceed after successful commit.

1.1.1 2020-09-25 13:19 UTC

This package is auto-updated.

Last update: 2020-09-25 13:47:11 UTC


README

Problem:

Solution:

By using this package you easily dispatch jobs inside transactions. Cancel job on transaction rollback. Add to queue on transaction committed.

Installation

This package requires PHP 7.1 and Laravel 5.8 or higher. If you are on a PHP version below 7.1 or a Laravel version below 5.8 just use an older version of this package.

  1. Run composer require therezor/laravel-transactional-jobs in your laravel project root folder

  2. Implement TheRezor\TransactionalJobs\Contracts\RunAfterTransaction to jobs that run in the middle of database transactions

<?php

use TheRezor\TransactionalJobs\Contracts\RunAfterTransaction;

class MySuperJob implements ShouldQueue, RunAfterTransaction
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    
    ...
}