bavix / laravel-wallet

It's easy to work with a virtual wallet
https://bavix.github.io/laravel-wallet/
MIT License
1.14k stars 230 forks source link

Error when try make depositFloat #147

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi.

In the last week when try register depositFloat has next error: image

I send an Wallet model image

I debug directly but "($this instanceof WalletModel ? $this->holder : $this)" return null, when make inverse "($this instanceof WalletModel ? $this : $this->holder)" works fine and register deposit, how do to work fine?? image

This is my code: Verify hasWallet and it's correct, then save $wallet and try to make depositFloat image

Model Customer has Wallet and HasWallets to have multiple wallets and user WalletFloat image

rez1dent3 commented 4 years ago

@fatnaydev Hello. I don’t have enough data. Need an example code.

ghost commented 4 years ago

@fatnaydev Hello. I don’t have enough data. Need an example code.

Updated with model and code

ghost commented 4 years ago

The problem is the same when createWallet and then try to forceWithdrawFloat

image

rez1dent3 commented 4 years ago

@fatnaydev This problem does not reproduce.

Screenshot from 2020-03-13 21-31-58

Screenshot from 2020-03-13 21-33-29

ghost commented 4 years ago

the strange thing that the system was working well and this week I mark the error but nothing has been moved to the code

@fatnaydev This problem does not reproduce.

rez1dent3 commented 4 years ago

@fatnaydev Please tell me which version of laravel you have installed? What version of library (laravel-wallet) are you using?

Depending on the version, see the changes: https://github.com/bavix/laravel-wallet/compare/4.1.2...4.2.0 https://github.com/bavix/laravel-wallet/compare/4.2.0...5.0.0

ghost commented 4 years ago

Laravel 6 Before error 4.2 and then update 5 to view the error gone but not

Another error appear In server show but in my local not image

Model Customer are the same image

@fatnaydev Please tell me which version of laravel you have installed? What version of library (laravel-wallet) are you using?

Depending on the version, see the changes: 4.1.2...4.2.0 4.2.0...5.0.0

rez1dent3 commented 4 years ago

@fatnaydev Use one trait: HasWallet or HasWaleltFloat.

ghost commented 4 years ago

@fatnaydev Use one trait: HasWallet or HasWaleltFloat.

Thanks, can share me the file test to run it un my local to test it please

rez1dent3 commented 4 years ago

@fatnaydev Unit tests are shared: https://github.com/bavix/laravel-wallet/tree/units/tests

And here is the unit test that I showed: https://github.com/bavix/laravel-wallet/blob/units/tests/MultiWalletTest.php#L93

rez1dent3 commented 4 years ago
git clone -b units https://github.com/bavix/laravel-wallet.git
cd laravel-wallet
composer install
./vendor/bin/phpunit
ghost commented 4 years ago

I find the problem, I have 2 models Customer and Prospect, the 2 models use the same table 'customers' the difference is 1 boolean field 'prospect' true is customer and false are prospect, in each model have an global scope to return respective registers using boolean 'prospect' field and the relation holder of model Wallet when is prospect not found it,

How do to add a 'withoutGlobalScopes' into holder relation to model wallet??

Customer image

Prospect image

the morph relation use customer model but the global scope return null because that customer is prospect image

git clone -b units https://github.com/bavix/laravel-wallet.git
cd laravel-wallet
composer install
./vendor/bin/phpunit
ghost commented 4 years ago

Yeap!

The solution are make model and config into config/wallet.php

image

rez1dent3 commented 4 years ago

@fatnaydev You correctly redefined the model. Thanks for information. I will know for the future.