File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 2323 - [ Refund] ( refund )
2424 - [ Gift] ( gift )
2525 - [ Cart] ( cart )
26+
27+ - Additions
28+
29+ - [ Wallet Swap] ( laravel-wallet-swap )
2630
2731- Multi Wallets
2832
Original file line number Diff line number Diff line change 1+ ## Laravel Wallet Swap
2+
3+ ## Composer
4+
5+ The recommended installation method is using [ Composer] ( https://getcomposer.org/ ) .
6+
7+ In your project root just run:
8+
9+ ``` bash
10+ composer req bavix/laravel-wallet-swap
11+ ```
12+
13+ ### User model
14+ We need a simple model with the ability to work multi-wallets.
15+
16+ ``` php
17+ use Bavix\Wallet\Interfaces\Wallet;
18+ use Bavix\Wallet\Traits\HasWallets;
19+ use Bavix\Wallet\Traits\HasWallet;
20+
21+ class User extends Model implements Wallet
22+ {
23+ use HasWallet, HasWallets;
24+ }
25+ ```
26+
27+ ### Simple example
28+ Find wallets and translate from one to another.
29+
30+ ``` php
31+ $usd = $user->getWallet('usd');
32+ $rub = $user->getWallet('rub');
33+
34+ $usd->balance; // int(200)
35+ $rub->balance; // int(0)
36+
37+ $usd->exchange(10, $rub);
38+ $usd->balance; // int(190)
39+ $rub->balance; // int(622)
40+ ```
41+
42+ It worked!
You can’t perform that action at this time.
0 commit comments