Skip to content

Commit

Permalink
docs: extending the base wallet class
Browse files Browse the repository at this point in the history
Signed-off-by: Kekeocha Justin Chetachukwu <[email protected]>
  • Loading branch information
justinkekeocha authored Sep 13, 2023
1 parent 80d31e8 commit b6227f9
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ php artisan vendor:publish --tag=laravel-wallet-config
```

After installing the package, you can proceed to [use it](basic-usage).

## Configure default wallet
You can customize the configuration file to suit certain needs. Example:

Customize `name` and `slug` of default wallet.
Expand All @@ -28,3 +28,31 @@ Customize `name` and `slug` of default wallet.
'meta' => [],
],
```
## Extend Wallet class
You can extend the Wallet class 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"; }
}
```

```php[config/wallet.php]
'wallet' => [
'table' => 'wallets',
'model' => MyWallet::class,
'creating' => [],
'default' => [
'name' => 'Default Wallet',
'slug' => 'default',
'meta' => [],
],
],
```
```php
echo $user->wallet->helloWorld();
```

0 comments on commit b6227f9

Please sign in to comment.