anourvalar/laravel-atom


README

Installation

composer require anourvalar/laravel-atom

Usage

Action after transaction commit

Atom::onCommit(function () {
    dispatch(new Job());
});

Action after transaction rollBack

Atom::onRollBack(function () {
    Storage::delete('file.jpg');
});

Pessimistic lock

Atom::lock('user');
Atom::lockUser($user->id); // equals to: Atom::lock('user', $user->id);

Optimistic lock

try {
    Atom::strategy('optimistic_transaction')->lock('week_report');
} catch (\AnourValar\LaravelAtom\Exceptions\OptimisticTransactionException $e) {
    // already in progress..
}