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

Batch Transfers

If you need multiple transfers between wallets, you can use a high-performance handle. It is worth remembering that the pen does not check the balance of the wallet before transferring, you need to take care of this yourself.

Previously, you would have written the following code:

use Zotel\Wallet\Services\AtomicServiceInterface;

app(AtomicServiceInterface::class)->block($from, function () use ($amount, $from, $wallets) {
    foreach ($wallets as $wallet) {
        $from->forceTransfer($wallet, $amount);
    }
});

This would lead to the generation of a huge number of requests to the database and cache, because. the package does not know that the response from forceTransfer is not used by you at all inside AtomicService. Now, you can report it:

use Zotel\Wallet\External\Api\TransferQuery;
use Zotel\Wallet\External\Api\TransferQueryHandlerInterface;

app(TransferQueryHandlerInterface::class)->apply(
    array_map(
        static fn (Wallet $wallet) => new TransferQuery($from, $wallet, $amount, null),
        $wallets
     )
);

The package will optimize queries and execute them in a single transaction. I strongly advise against creating large packs, because. this can lead to a large increase in request queuing.


In version 10.x, it became possible to create transactions&transfers with a given uuid (generate on the client side). The main thing is to keep uniqueness.

use Zotel\Wallet\External\Api\TransferQuery;

// int version
new TransferQuery($from, $wallet, $amount, new \Zotel\Wallet\External\Dto\Extra(
    deposit: new \Zotel\Wallet\External\Dto\Option(
        null,
        uuid: '71cecafe-da10-464f-9e00-c80437bb4c3e', // deposit transaction
    ),
    withdraw: new \Zotel\Wallet\External\Dto\Option(
        null,
        uuid: '3805730b-39a1-419d-8715-0b7cc3f1ffc2', // withdraw transaction
    ),
    uuid: 'f8becf81-3993-43d7-81f1-7a725c72e976', // transfer uuid
    extra: ['info' => 'fast deposit'], // metadata in the table transfers
));

// float version
new TransferFloatQuery($from, $wallet, $amountFlaot, new \Zotel\Wallet\External\Dto\Extra(
    deposit: new \Zotel\Wallet\External\Dto\Option(
        null,
        uuid: '71cecafe-da10-464f-9e00-c80437bb4c3e', // deposit transaction
    ),
    withdraw: new \Zotel\Wallet\External\Dto\Option(
        null,
        uuid: '3805730b-39a1-419d-8715-0b7cc3f1ffc2', // withdraw transaction
    ),
    uuid: 'f8becf81-3993-43d7-81f1-7a725c72e976', // transfer uuid
    extra: ['info' => 'fast deposit'], // metadata in the table transfers
));

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.
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
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle