nobelatunje / wallet
Wallet - A simple Laravel Wallet Package
Installs: 165
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 1
Forks: 5
Open Issues: 0
Type:project
Requires
- php: ^7.3|^8.0
- illuminate/support: ^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: 9.5.x-dev
This package is auto-updated.
Last update: 2025-01-04 09:12:38 UTC
README
A simple laravel package for wallet implementation.
This package can basically be plugged into a laravel project and it will handle wallet transactions. It allows for a user to have multiple wallets that can be given different names.
How to install
Install via composer
$ composer install nobelatunje/wallet
Copy the database migrations to your migrations folder and run
$ php artisan migrate
To create a wallet
$wallet = Wallet::create($user_id, "Car Savings Wallet");
To get user's wallets
$wallet = $this->hasMany(Wallet::class, 'user_id');
To credit a wallet
$wallet->credit(2000, "Payment for order #849494");
To debit a wallet
$wallet->debit(1000, "Purchase of airtime");
To reverse a transaction
$wallet = Wallet::find(2); $transaction = Transaction::find(3); $wallet->reverseTransaction($transaction);
To view wallet transactions
Wallet::find(2)->transactions();
To retrieve wallets
Wallet::all();
To delete a wallet
Wallet::find(2)->delete();