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

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->transfer(
    $user2,
    511,
    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 HasWallet, he will have balance property. Check the user's balance.

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

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

$first->transfer($last, 5); 
$first->balance; // 95
$last->balance; // 5

It's simple!

Force Transfer

Check the user's balance.

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

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

$first->forceTransfer($last, 500); 
$first->balance; // -400
$last->balance; // 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.
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
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium