https://github.com/nattaponra/larawallet
Laravel Wallet System.
https://github.com/nattaponra/larawallet
laravel laravel-framework php wallet
Last synced: over 1 year ago
JSON representation
Laravel Wallet System.
- Host: GitHub
- URL: https://github.com/nattaponra/larawallet
- Owner: nattaponra
- License: mit
- Created: 2018-06-16T06:05:56.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-25T07:05:12.000Z (about 8 years ago)
- Last Synced: 2025-03-27T04:51:24.875Z (over 1 year ago)
- Topics: laravel, laravel-framework, php, wallet
- Language: PHP
- Homepage:
- Size: 56.6 KB
- Stars: 12
- Watchers: 3
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Lara Wallet
Lara wallet is a wallet system package that allow you fast develop wallet system in laravel framework.
## Features
- Balance checking
- Deposition
- Withdrawal
- Transfer
- fee
- SanBox Mode
## 1. Installation
Install the package with composer:
```bash
composer require nattaponra/larawallet
```
## 2. Run Migrations
Publish the migrations and config file with this artisan command:
```bash
php artisan vendor:publish --provider="nattaponra\LaraWallet\LaraWalletServiceProvider"
```
Run migration file to create database tables:
```bash
php artisan migrate
```
## 3. Wallet using with user model.
Add 'HasWallet' trait in User model (app/User.php):
And Add 'HasSanBoxWallet' trait for sanbox mode.
```bash
class User extends Authenticatable
{
use HasWallet;
use HasSanBoxWallet;
......
}
```
## 4. Using
Create example user
```bash
$user = Auth::user();
```
Balance checking
```bash
echo $user->wallet->balance()
```
Deposition
```bash
$user->wallet->deposit(100);
```
Withdrawal
```bash
$user->wallet->withdraw(5000);
```
Transfer
```bash
$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
```bash
$user->sanBoxWallet->balance();
```
## Option