Seamlessly integrate wallet processing functionality into your Laravel application. This package enables you to effortlessly increase and decrease the wallet balance for each user, as well as retrieve their current wallet balance, freeing you to concentrate on developing your application's core features.
- Allow users to have individual wallets associated with their accounts
- Provide methods to increase and decrease the wallet balance for each user
- Keep a record of wallet transactions for auditing and user reference
- Implement secure authorization mechanisms to ensure only authorized users can perform wallet operations
You can install the package with Composer:
composer require roshandelpoor/laravel-walletIf you want to publish a config file, you can use this command:
php artisan vendor:publish --tag="laravel-wallet-config"If you want to publish the migrations, you can use this command:
php artisan vendor:publish --tag="laravel-wallet-migrations"For convenience, you can use this command to publish config, migration, and ... files:
php artisan vendor:publish --provider="Roshandelpoor\LaravelWallet\Providers\LaravelWalletServiceProvider"After publishing, run the php artisan migrate command.
For storing a new wallet, you can use Wallet model:
use \Roshandelpoor\LaravelWallet\Models\Wallet;
use Illuminate\Support\Facades\DB;
try {
DB::beginTransaction();
$wallet = Wallet::query()->firstOrCreate([
'user_id' => $user->id,
'balance' => $amount
]);
$WalletLogs = new WalletLog([
'ownable_id' => $ownable->id,
'ownable_type' => $ownable::class,
'amount' => $amount
]);
DB::commit();
} catch (\Exception $e) {
report($e);
DB::rollBack();
}If you want to access to user wallet, you can use like this:
$wallet = Wallet::query()->find([
'user_id' => $user->id
])
->with('walletLogs');If you find any bugs or have suggestions for new features, feel free to open an issue or submit a pull request on GitHub.
Laravel Wallet is open-source software licensed under the MIT license.