Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Create configuration.md #771

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.