Lara wallet is a wallet system package that allow you fast develop wallet system in laravel framework.
- Balance checking
- Deposition
- Withdrawal
- Transfer
- fee
- SanBox Mode
Install the package with composer:
composer require nattaponra/larawallet
Publish the migrations and config file with this artisan command:
php artisan vendor:publish --provider="nattaponra\LaraWallet\LaraWalletServiceProvider"
Run migration file to create database tables:
php artisan migrate
Add 'HasWallet' trait in User model (app/User.php): And Add 'HasSanBoxWallet' trait for sanbox mode.
class User extends Authenticatable
{
use HasWallet;
use HasSanBoxWallet;
......
}
Create example user
$user = Auth::user();
Balance checking
echo $user->wallet->balance()
Deposition
$user->wallet->deposit(100);
Withdrawal
$user->wallet->withdraw(5000);
Transfer
$user1 = User::find(1);
$user2 = User::find(2);
$user1->wallet->deposit(15000);
$user1->wallet->transfer(1000,$user2);
echo $user1->wallet->balance(); #14000
echo $user2->wallet->balance(); #1000
SanBox Mode
$user->sanBoxWallet->balance();