Closed Basheer21 closed 1 month ago
Hello.
$business->balance : should retrieve the correct balance
This is an appeal to the default wallet, and you are replenishing a multi-wallet.
If you want to get his balance, the code should be like this:
$business->getWallet('business-wallet')->balance;
If you need multi-wallets and do not need the default wallet, then disable it leaving only the HasWallets
trait.
That is, remove HasWalletFloat or HasWallet.
Thanks a lot for your fast support.
The balance attribute in the modelInstance is returning 0 when accessed via modelInstance->balance, even though querying the associated Wallet model directly returns the correct balance
To Reproduce Steps to reproduce the behavior:
create a wallet for the modelInstance ex: $business->createWallet([ 'name' => $business->name . ' Wallet', 'slug' => 'business-wallet', ]);
make deposit $business->getWallet('business-wallet')->deposit(100000); // pls note if i do $business->deposit(100000); without specifying the walletName its gonna create another wallet
check balance: $business->balance will retrieve 0 while if I check the balance using the wallet Model will bring the correct balance ex/ $wallet = Wallet::where('holder_id', 2)->get();
Expected behavior $business->balance : should retrieve the correct balance