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

creating balance of the wallet by default #346

Closed ahmed-mohammed1 closed 3 years ago

ahmed-mohammed1 commented 3 years ago

creating balance of the wallet by default not working when i use $user->balance it showing this error

"message": "Attempt to read property \"exists\" on null",
"exception": "ErrorException",
"file": "/home/bootfi/Desktop/backend/vendor/bavix/laravel-wallet/src/Services/WalletService.php",
"line": 130,
rez1dent3 commented 3 years ago

Hello. More information needed:

ahmed-mohammed1 commented 3 years ago

ok Laravel v8.52.0 PHP v8.0.7 MySql v8.0.26 package 6.1

here is my Customer model class Customer extends Model implements \Bavix\Wallet\Interfaces\Customer { use Uuids, SoftDeletes, HasFactory, LogsActivity, CanPay; . . . }

and my Order model class Order extends Model implements Product, Taxable { use Uuids, SoftDeletes, HasFactory, LogsActivity, HasWallet; . . . public function canBuy(Customer $customer, int $quantity = 1, bool $force = null): bool { /**

i want to test the balance value. but it gave me that error

rez1dent3 commented 3 years ago

I have reproduced the problem. The problem is in the UUID of the user, at the moment you can only use integer values in the primary key.

Unfortunately, this problem cannot be fixed in the library. I've had many attempts to drag int and uuid into the library, but backward compatibility breaks a lot.

I am currently working on a draft for the next version and will pay special attention to UUIDs.

rez1dent3 commented 3 years ago

the problem arises in the connection between the wallet and the user, the package cannot create the wallet and we receive an error

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity.