Skip to content

Conversation

@rez1dent3
Copy link
Contributor

Hello.

I proposed an additional event (committing #44608) in laravel, but the PR was closed. Maybe then we can at least move the commit logic into one protected method? It will greatly simplify the application logic for me.

Thanks

@taylorotwell
Copy link
Member

What problem are you trying to solve in your application?

@rez1dent3
Copy link
Contributor Author

I am developing a package for virtual wallets. For the duration of the transaction, wallets are blocked. In order not to make unnecessary requests to the database to update the balance, I need to update wallets before commit (those inside the transaction).

Here is the pseudocode:

DB::beginTransaction();
$wallet1->deposit(100);
$wallet2->deposit(100);
$wallet5->deposit(100);
DB::commit();

Not to do after each insert query update I need access to commit. Then the code will look like this:

start transaction;
insert into trans (wallet_id, amount, ...) values (1, 100, ...); // q1
insert into trans (wallet_id, amount, ...) values (2, 100, ...); // q2
insert into trans (wallet_id, amount, ...) values (5, 100, ...); // q3

... update case when ... then...
 commit;

My case is quite narrow, but I really need to have access before the commit operation.

@rez1dent3
Copy link
Contributor Author

The performCommit method implemented is an analogue of the performRollBack method, which has been in the framework for a long time.

@rez1dent3
Copy link
Contributor Author

Specifically, at the moment, I want to abandon the "own" implementation of transactions (which internally uses the standard one) in favor of the standard ones. With this change, I can add full support for laravel nova, but now there are only problems. bavix/laravel-wallet#455 bavix/laravel-wallet#569

@taylorotwell
Copy link
Member

Reopening other PR.

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.

2 participants