When there is enough money in the account, you can transfer/withdraw it or buy something in the system.
Since the currency is virtual, you can buy any services on your website. For example, priority in search results.
Find user:
$user = User::first();
As the user uses HasWalletFloat, he will have balance property.
Check the user's balance.
$user->balance; // 10000
$user->balanceInt; // 10000
$user->balanceFloatNum; // 100.00
The balance is not empty, so you can withdraw funds.
$user->withdrawFloat(10);
$user->balance; // 9000
$user->balanceInt; // 9000
$user->balanceFloatNum; // 90.00
It's simple!
Forced withdrawal is necessary for those cases when the user has no funds. For example, a fine for spam.
$user->balanceFloatNum; // 90.00
$user->forceWithdrawFloat(101);
$user->balanceFloatNum; // -11.00
There can be two situations:
Zotel\Wallet\Exceptions\BalanceIsEmptyZotel\Wallet\Exceptions\InsufficientFundsHow can I help you explore Laravel packages today?