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

Update Transfer Model #858

Merged
merged 3 commits into from
Jan 23, 2024
Merged

Update Transfer Model #858

merged 3 commits into from
Jan 23, 2024

Conversation

gkmk
Copy link
Contributor

@gkmk gkmk commented Jan 23, 2024

Update Transfer model to support dynamic loading of overwritten Wallet or Transaction model classes.

Defaults to current Wallet and Transaction model from inside the package if no overwritten models specified.

gkmk added 2 commits January 23, 2024 12:21
Update Transfer model to support dynamic loading of overwritten Wallet or Transaction model classes.
Defaults to current Wallet and Transaction model from inside the package if no overwritten models specified.

Signed-off-by: George Klincarski <[email protected]>
Transfer model has `from` and `to` relationships that actually morphed in the database.
This change reflects that on the model too.

Signed-off-by: George Klincarski <[email protected]>
Copy link
Member

@rez1dent3 rez1dent3 left a comment

Choose a reason for hiding this comment

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

Regarding the configuration, I don't mind, you're right. But there is no need to return morphTo. To_type & from_type will be removed in version 11.x.

src/Models/Transfer.php Outdated Show resolved Hide resolved
src/Models/Transfer.php Outdated Show resolved Hide resolved
@rez1dent3
Copy link
Member

@gkmk Also, I ask you to write a unit test for this code, if it’s not difficult for you.

@rez1dent3
Copy link
Member

@gkmk I looked at your code carefully and realized that this code is not necessary.
I added the following a long time ago and in the connections you should get the correct model.

        $this->app->bind(Transaction::class, $configure['transaction']['model'] ?? null);
        $this->app->bind(Transfer::class, $configure['transfer']['model'] ?? null);
        $this->app->bind(Wallet::class, $configure['wallet']['model'] ?? null);

See: #859

@rez1dent3 rez1dent3 added need details no problem There is a description in the documentation. This is how it should work. labels Jan 23, 2024
src/Models/Transfer.php Show resolved Hide resolved
src/Models/Transfer.php Show resolved Hide resolved
@gkmk
Copy link
Contributor Author

gkmk commented Jan 23, 2024

@rez1dent3 i see. I think we should check the migrations then because i switched to morph to relationship just because of the database structure.
About the belongs to relationships i find the definition on the model better just because it is not as magical as container binding and the responsibility is kept in one place. I also noticed that this is the pattern you have used inside other models. So it just keeps consistency.

@rez1dent3
Copy link
Member

rez1dent3 commented Jan 23, 2024

@gkmk okay. revert the changes with morphTo and I will merge.

Signed-off-by: George Klincarski <[email protected]>
@rez1dent3 rez1dent3 removed need details no problem There is a description in the documentation. This is how it should work. labels Jan 23, 2024
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fff328f) 100.00% compared to head (c4cad87) 100.00%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##              master      #858   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       552       552           
===========================================
  Files             83        83           
  Lines           1949      1949           
===========================================
  Hits            1949      1949           

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

@rez1dent3 rez1dent3 merged commit db0014f into bavix:master Jan 23, 2024
104 of 107 checks passed
rez1dent3 added a commit that referenced this pull request Jan 23, 2024
@gkmk gkmk deleted the patch-1 branch January 23, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants