Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Wallet Laravel Package

zotel/laravel-wallet

View on GitHub
Deep Wiki
Context7

Withdraw

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.

User Model

Make a Withdraw

Find user:

$user = User::first(); 

As the user uses HasWallet, he will have balance property. Check the user's balance.

$user->balance; // 100
$user->balanceInt; // 100

The balance is not empty, so you can withdraw funds.

$user->withdraw(10); 
$user->balance; // 90
$user->balanceInt; // 90

It's simple!

Force Withdraw

Forced withdrawal is necessary for those cases when the user has no funds. For example, a fine for spam.

$user->balance; // 100
$user->balanceInt; // 100
$user->forceWithdraw(101);
$user->balance; // -1
$user->balanceInt; // -1

And what will happen if the money is not enough?

There can be two situations:

  • The user's balance is zero, then we get an error Zotel\Wallet\Exceptions\BalanceIsEmpty
  • If the balance is greater than zero, but it is not enough Zotel\Wallet\Exceptions\InsufficientFunds
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver