Weave 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

Transfer

Transfer in our system are two well-known Deposit and Withdraw operations that are performed in one transaction.

The transfer takes place between wallets.

User Model

Example contract

$transfer = $user1->transferFloat(
    $user2,
    5.11,
    new Extra(
        deposit: [
            'type' => 'extra-deposit',
        ],
        withdraw: new Option(
            [
                'type' => 'extra-withdraw',
            ],
            false // confirmed
        ),
        extra: [
            'msg' => 'hello world',
        ],
    )
);

Make a Transfer

Find user:

$first = User::first(); 
$last = User::orderBy('id', 'desc')->first(); // last user
$first->getKey() !== $last->getKey(); // true

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

$fist->balanceFloatNum; // 100.00
$last->balanceFloatNum; // 0

The transfer will be from the first user to the second.

$first->transferFloat($last, 5); 
$first->balanceFloatNum; // 95
$last->balanceFloatNum; // 5

It's simple!

Force Transfer

Check the user's balance.

$first->balanceFloatNum; // 100
$last->balanceFloatNum; // 0

The transfer will be from the first user to the second.

$first->forceTransferFloat($last, 500); 
$first->balanceFloatNum; // -400
$last->balanceFloatNum; // 500

It's simple!

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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels