laravel-user-wallet maintained by mahbodhastam
Description
This package allows you to create wallet for the users
Author
Last update
2021/08/16 16:48
(dev-main)
License
Downloads
5
Tags
Laravel User Wallet
With this package you can create wallet for the users.
Note: Make sure you've already installed php ^8
Installation
Install the package via composer:
composer require mahbodhastam/laravel-user-wallet
Usage
-
Create New Wallet
use MahbodHastam\UserWallet\UserWallet;
$wallet = UserWallet::createNewWallet(user_id: 1);
$amount = $wallet->amount;
$token = $wallet->token;
-
Get wallet with the token/id
$wallet = UserWallet::getWallet('abc');
-
Get wallet's balance
$balance = UserWallet::balance($wallet)['total'];
-
Change wallet's amount
UserWallet::fill($wallet, 100);
-
Charge the wallet
UserWallet::charge($wallet, 500);
-
Send
UserWallet::send(
sender: $wallet1,
receiver: $wallet2,
value: 50
);
-
Open a request
$transaction = UserWallet::makeRequest(
value: 300,
receiver: $wallet
);
// Keep it
$hash = $transaction->transaction_hash;
UserWallet::closeRequest(
sender: $wallet,
transaction_hash: $hash
);
-
Get the balance in blade
@userWalletBalance($wallet)
{{-- $wallet can be wallet's `id`, `token` or an instance from UserWalletModel --}}
See the Tests for more examples.
Testing
composer test
Todos
- Blade Directives
Changelog
See CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.