-
-
Notifications
You must be signed in to change notification settings - Fork 240
Total amount per transaction #416
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
Comments
Hello.
like this.
So it happened historically, but now this "feature" bothers me a little. But I don't want to break the package's backward compatibility. You can easily achieve the desired result by adding where. $wallet->transactions()->where('wallet_id', $wallet->getKey())->...
Details are needed here, I did not understand your question. |
I decided to try adding a new method |
Hello DB :: transaction (function () { It stopped working, and erroneously, the transaction was generated but the amount of the wallet was not withdrawn. I tried the package's transactions function and everything worked correctly, but I still don't understand why my code block stopped working. Another thing I wanted to know is how to verify that the sum of the amount of all transactions is equivalent to the total amount of a wallet, is there a package function for this? Or should I create it by eloquent. I need this for the reason that as I progress in my project, it is verified that no error occurs in the transactions. |
The update takes place not only in the database, but also in the storage. There is no way to implement atomicity at the transaction level. Package operations are atomic and will not let you get shot in the foot if you work with the package correctly. If you need to combine several operations into one transaction, then you need to upgrade the package to version 7.1 and work through the package functions. More details here: https://bavix.github.io/laravel-wallet/#/transaction |
I have freed myself from my affairs and there is time to respond in more detail. The fact is that the package never declared to work with laravel transactions and until version 7.1, when using your case, the data was not inserted / updated into the database, but was updated in the storage (see the section race condition). I described the problem in more detail here: #412 If you want to maintain data atomicity, then you need to work with the internal transaction interface. It is optimized to work with the package and does not violate the atomicity of the data between the database and the store. This interface allowed us to get rid of unnecessary updates in the database, which gave a big performance boost for 7.x. More details can be found here: https://github.com/bavix/laravel-wallet-benchmark Now the package does not make +100500 database updates for the wallet, but only updates the state. Upon completion of the transaction, writes to the database. If you wrap in your own transaction, then you need to repeat everything that the package does inside. |
Could you give more detail about how the transactions work? and how it is connected to the wallet. What do you mean by data atomicity? Could you show a diagram of the process of how a transaction is generated, please Regarding the transfers, I will update the package to test the new features, thank you. |
You'd better look at the pull request #412, it's all there. Atomicity is an indivisible operation. Either applied or rolled back. |
This issue is stale because it has been open 21 days with no activity. |
Hello, I have been reviewing the package I really liked the truth and I would like to add on my own a 'total' attribute within the transactions to know the total amount of my wallet after having made that transaction, in order to know how much balance I had in a given transaction.
I'm not sure whether to add the attribute into the meta array or add a column, but I would like to know in which section I could modify this, without touching the vendor folder.
I have other questions, how can I get a list of transactions by wallet? I have dealt with '$wallet-> transactions' but it returns all transactions by user.
And one last question, when generating a transaction, the package already includes a function to verify that the aggregate balance is correct? That is, to verify that the 'balance' of a wallet is correct, I must compare it with the sum of the transactions of this wallet.
The text was updated successfully, but these errors were encountered: