Skip to content

Commit e130196

Browse files
committed
add docs laravel-wallet-swap
1 parent 778d049 commit e130196

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

docs/_sidebar.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
- [Refund](refund)
2424
- [Gift](gift)
2525
- [Cart](cart)
26+
27+
- Additions
28+
29+
- [Wallet Swap](laravel-wallet-swap)
2630

2731
- Multi Wallets
2832

docs/laravel-wallet-swap.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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!

0 commit comments

Comments
 (0)