nobelatunje/wallet

Wallet - A simple Laravel Wallet Package

Maintainers

Details

github.com/Atunje/wallet

Source

Issues

Installs: 165

Dependents: 0

Suggesters: 0

Security: 0

Stars: 9

Watchers: 1

Forks: 5

Open Issues: 0

Type:project

dev-master 2021-11-20 07:01 UTC

This package is auto-updated.

Last update: 2024-04-20 12:31:41 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();