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

Add payments relation on wallet #874

Closed
wants to merge 5 commits into from
Closed

Add payments relation on wallet #874

wants to merge 5 commits into from

Conversation

gkmk
Copy link
Contributor

@gkmk gkmk commented Jan 30, 2024

This adds functionality to query the database for transfers in the other direction, payments. Lookup what transfers happened from another wallet to this one.

gkmk added 2 commits January 30, 2024 11:02
This adds functionality to query the database for transfers in the other direction, payments. Lookup what transfers happened from another wallet to this one.

Signed-off-by: George Klincarski <[email protected]>
Add payments relation on wallet
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (387a348) 100.00% compared to head (cedac1c) 99.75%.

Files Patch % Lines
src/Models/Wallet.php 0.00% 5 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              master     #874      +/-   ##
=============================================
- Coverage     100.00%   99.75%   -0.25%     
- Complexity       581      582       +1     
=============================================
  Files             88       88              
  Lines           2029     2034       +5     
=============================================
  Hits            2029     2029              
- Misses             0        5       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gkmk
Copy link
Contributor Author

gkmk commented Jan 30, 2024

Ill add tests if this is accepted

*
* @return HasMany<Transfer>
*/
public function payments(): HasMany
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This should be in the Wallet model;
  2. The name is not good, because this is the receipt of a transfer (there are transactions: transfer, exchange, payment);
  3. No unit tests;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what should this relationship be called?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call it like this:

receivedTransfers

I don't have a better idea.


According to the unit test, it is not necessary to write a new one. It is enough to pull a new method in an existing test and check the number of elements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, most importantly. If you want a feature now, then PR must be done from the 10.x branch.

If from the master, then it is already 11.x, and this version will not support laravel 10.x

@rez1dent3
Copy link
Member

Ill add tests if this is accepted

okay.

Please specify for which version the change is needed? 10.x or 11.x

@rez1dent3
Copy link
Member

rez1dent3 commented Jan 31, 2024

@gkmk

Please specify for which version the change is needed? 10.x or 11.x

Why am I asking this question? If for version 11.x, then I deceived you. This should be HasWallet + add to the contract \Bavix\Wallet\Interfaces\Wallet.

And if for version 10.x, then it should be in the Wallet model.

UPD: The bottom line is that you cannot make changes that break backward compatibility. And version 11.x has not yet been released.

@rez1dent3 rez1dent3 added the enhancement New feature or request label Jan 31, 2024
@gkmk
Copy link
Contributor Author

gkmk commented Jan 31, 2024 via email

@rez1dent3
Copy link
Member

Yeah, it's great. Then for 11.x from the master branch, and for 10.x from the 10.x branch, I have already written files. For 11.x -- HasWallet, as you did initially. But for 10.x -- Wallet model. This is necessary for backward compatibility

@gkmk
Copy link
Contributor Author

gkmk commented Feb 1, 2024

I will close this PR in favor of 2 new ones based of their appropriate branches.

@gkmk gkmk closed this Feb 1, 2024
@gkmk
Copy link
Contributor Author

gkmk commented Feb 1, 2024

But for 10.x -- Wallet model. This is necessary for backward compatibility

Working on this makes test awkward. Have to update tests/Infra/Models/Buyer.php with the same function from the Wallet model now.
But since the Wallet model uses src/Traits/HasWallet.php why are we not updating this trait and the model instead in v10?

@rez1dent3
Copy link
Member

rez1dent3 commented Feb 1, 2024

@gkmk Then you will have to change the contract, and for this you need to change the major version.

It's slightly longer and remains 99.9% backwards compatible:

$user->wallet->receivedTransfers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants