2017 © Pedro Peláez
 

library laravel-wallet

Easy to use virtual wallet for your app

image

depsimon/laravel-wallet

Easy to use virtual wallet for your app

  • Monday, July 16, 2018
  • by depsimon
  • Repository
  • 4 Watchers
  • 7 Stars
  • 81 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 9 Versions
  • 161 % Grown

The README.md

Laravel Wallet

In a few projects I had to implement a virtual currency. The user would buy packs of credits with Stripe and then use them in the app in exchange of services or goods. This package is a small and simple implementation of this concept with place for customization., (*1)

Installation

Install the package with composer:, (*2)

composer require depsimon/laravel-wallet

Run Migrations

Publish the migrations with this artisan command:, (*3)

php artisan vendor:publish --provider="Depsimon\Wallet\WalletServiceProvider" --tag=migrations

Configuration

You can publish the config file with this artisan command:, (*4)

php artisan vendor:publish --provider="Depsimon\Wallet\WalletServiceProvider" --tag=config

This will merge the wallet.php config file where you can specify the Users, Wallets & Transactions classes if you have custom ones., (*5)

Usage

Add the HasWallet trait to your User model., (*6)

``` php, (*7)

use Depsimon\Wallet\HasWallet;, (*8)

class User extends Model { use HasWallet;, (*9)

...

}, (*10)


At some point before making transactions, create the user's wallet. ```php $user->wallet()->create();

Then you can easily make transactions from your user model., (*11)

``` php $user = User::find(1); $user->balance; // 0, (*12)

$user->deposit(100); $user->balance; // 100, (*13)

$user->withdraw(50); $user->balance; // 50, (*14)

$user->forceWithdraw(200); $user->balance; // -150, (*15)


You can easily add meta information to the transactions to suit your needs. ``` php $user = User::find(1); $user->deposit(100, 'deposit', ['stripe_source' => 'ch_BEV2Iih1yzbf4G3HNsfOQ07h', 'description' => 'Deposit of 100 credits from Stripe Payment']); $user->withdraw(10, 'withdraw', ['description' => 'Purchase of Item #1234']);

Security

If you discover any security related issues, please email simon@webartisan.be instead of using the issue tracker., (*16)

Credits

License

The MIT License (MIT). Please see License File for more information., (*17)

The Versions

16/07 2018

dev-master

9999999-dev https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

16/07 2018

v1.0.7

1.0.7.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

05/04 2018

v1.0.6

1.0.6.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

02/03 2018

v1.0.5

1.0.5.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

22/02 2018

v1.0.4

1.0.4.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

22/02 2018

v1.0.3

1.0.3.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

22/02 2018

v1.0.2

1.0.2.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

22/02 2018

v1.0.1

1.0.1.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet

22/02 2018

v1.0.0

1.0.0.0 https://github.com/depsimon/laravel-wallet

Easy to use virtual wallet for your app

  Sources   Download

MIT

The Requires

 

currency virtual wallet depsimon credits laravel-wallet