Skip to content

Commit 9c175bc

Browse files
authored
Update README.md
1 parent 608bba4 commit 9c175bc

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,46 @@ laravel-wallet - Easy work with virtual wallet.
1919
* **PHP Version**: 7.1+
2020
* **[Composer](https://getcomposer.org/):** `composer require bavix/laravel-wallet`
2121

22+
### Run Migrations
23+
Publish the migrations with this artisan command:
24+
```
25+
php artisan vendor:publish --provider="Depsimon\Wallet\WalletServiceProvider" --tag=migrations
26+
```
27+
28+
### Configuration
29+
You can publish the config file with this artisan command:
30+
```
31+
php artisan vendor:publish --provider="Depsimon\Wallet\WalletServiceProvider" --tag=config
32+
```
33+
34+
### Usage
35+
Add the HasWallet trait to model.
36+
```
37+
use Bavix\Wallet\Traits\HasWallet;
38+
use Bavix\Wallet\Interfaces\Wallet;
39+
40+
class User extends Model implements Wallet
41+
{
42+
use HasWallet;
43+
}
44+
```
45+
46+
Now we make transactions.
47+
48+
```
49+
$user = User::first();
50+
$user->balance; // int(0)
51+
52+
$user->deposit(10);
53+
$user->balance; // int(10)
54+
55+
$user->withdraw(1);
56+
$user->balance; // int(9)
57+
58+
$user->forceWithdraw(200);
59+
$user->balance; // -191
60+
```
61+
2262
---
2363
Supported by
2464

0 commit comments

Comments
 (0)