LaravelPackages.net
Acme Inc.
Toggle sidebar
theamostafa/laravel-wallet

This is my package laravel-wallet

285
1
1.0.0
About theamostafa/laravel-wallet

theamostafa/laravel-wallet is a Laravel package for this is my package laravel-wallet. It currently has 1 GitHub stars and 285 downloads on Packagist (latest version 1.0.0). Install it with composer require theamostafa/laravel-wallet. Discover more Laravel packages by theamostafa or browse all Laravel packages to compare alternatives.

Last updated

Laravel wallet

Light package help you to integrate wallet functionality into your laravel application

Installation

You can install the package via composer:

composer require theamostafa/laravel-wallet

You can publish and run the migrations with:

php artisan vendor:publish --tag="wallet-migrations"
php artisan migrate

Usage

include HasWallet trait into your model to apply wallet functions

use Theamostafa\Wallet\Traits\HasWallet;

class User extends Model {

  use HasWallet;

}

Now we make transactions.

$user = User::first();
$user->balance; // 0

$user->deposit(10);
$user->balance; // 10

$user->withdraw(1);
$user->balance; // 9

You can also add metadata for transaction

$user = User::first();

$transaction = $user->withdraw(
        amount: 1.33,
        meta: [
            'description' => "Refund from order #14"
        ]
    );
    $transaction->description // Refund from order #14
 

Fetch all model transactions.

$user = User::first();

$user->transactions()->latest()->paginate(); 

Testing

composer test

Credits

Features coming with version 2

  • Model may be having multiple wallet
  • Wallet may be acted as payment gateway and can purchase products

License

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

Comments