Skip to content

Commit

Permalink
docs: Create configuration.md
Browse files Browse the repository at this point in the history
Move package configuration to a separate section

Signed-off-by: Kekeocha Justin Chetachukwu <[email protected]>
  • Loading branch information
justinkekeocha authored Sep 14, 2023
1 parent 80d31e8 commit d328a37
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Configuration
Though this package is crafted to suit most of your needs by default, you can edit the configuration file to suit certain demands.

## Configure default wallet
Customize `name`,`slug` and `meta` of default wallet.

```php[config/wallet.php]
'default' => [
'name' => 'Ethereum',
'slug' => 'ETH',
'meta' => [],
],
```
## Extend base Wallet model
You can extend base Wallet model by creating a new class that extends `Bavix\Wallet\Models\Wallet` and registering the new class in `config/wallet.php`.
Example `MyWallet.php`

```php[App/Models/MyWallet.php]
use Bavix\Wallet\Models\Wallet as WalletBase;
class MyWallet extends WalletBase {
public function helloWorld(): string { return "hello world"; }
}
```
### Register base Wallet model

```php[config/wallet.php]
'wallet' => [
'table' => 'wallets',
'model' => MyWallet::class,
'creating' => [],
'default' => [
'name' => 'Default Wallet',
'slug' => 'default',
'meta' => [],
],
],
```
```php
echo $user->wallet->helloWorld();
```
This same method above, can be used to extend the base `Transfer` and `Transaction` models and registering the extended models in the configuration file.

0 comments on commit d328a37

Please sign in to comment.