PHPackages                             yasser-elgammal/laravel-easy-wallet - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yasser-elgammal/laravel-easy-wallet

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yasser-elgammal/laravel-easy-wallet
===================================

A package to make easy wallet for laravel projects.

v1.1.0(3w ago)992[2 PRs](https://github.com/YasserElgammal/easy-wallet/pulls)MITPHP

Since Jul 18Pushed 3w agoCompare

[ Source](https://github.com/YasserElgammal/easy-wallet)[ Packagist](https://packagist.org/packages/yasser-elgammal/laravel-easy-wallet)[ RSS](/packages/yasser-elgammal-laravel-easy-wallet/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (4)Versions (9)Used By (0)

Laravel Easy Wallet
===================

[](#laravel-easy-wallet)

**Laravel Easy Wallet** is a simple, secure, and highly extensible wallet system for Laravel applications. It allows you to associate wallets with any model, manage balances, and record transactions safely with concurrency protection, custom exceptions, and event dispatches.

🚀 Features
----------

[](#-features)

- **Wallet Association**: Attach a wallet to any Eloquent model (`Walletable` contract).
- **Concurrency Safe**: Uses `lockForUpdate` on DB transactions to prevent race conditions during debits and transfers.
- **Transaction History**: Tracks all `credit` and `debit` operations with secure UUIDs.
- **Events System**: Dispatches Laravel events upon transaction completion (`WalletCredited`, `WalletDebited`, `WalletTransferCompleted`).
- **Custom Exceptions**: Easy-to-catch exceptions (`InsufficientBalanceException`, `WalletNotFoundException`, `InvalidAmountException`).
- **Highly Extensible**: Change the package's internal models easily via configuration.

📦 Installation
--------------

[](#-installation)

```
composer require yasser-elgammal/laravel-easy-wallet
```

💸 Usage
-------

[](#-usage)

### 1. Implement `Walletable` and add `HasWallet` Trait

[](#1-implement-walletable-and-add-haswallet-trait)

Implement the `Walletable` contract and add the `HasWallet` trait into models that need wallets.

```
use Illuminate\Database\Eloquent\Model;
use YasserElgammal\LaravelEasyWallet\Contracts\Walletable;
use YasserElgammal\LaravelEasyWallet\Traits\HasWallet;

class User extends Model implements Walletable
{
    use HasWallet;

    /**
     * Automatically create a wallet when the model is created.
     * Default is [true]. Set to false to disable auto creation.
     */
    protected bool $autoCreateWallet = true;
}
```

### 2. Credit Wallet

[](#2-credit-wallet)

```
use YasserElgammal\LaravelEasyWallet\Facades\EasyWallet;
use App\Models\User;

$user = User::find(1);

EasyWallet::credit($user, 100.00, 'Initial deposit');
```

### 3. Debit Wallet

[](#3-debit-wallet)

```
try {
    EasyWallet::debit($user, 25.00, 'Purchased course');
} catch (\YasserElgammal\LaravelEasyWallet\Exceptions\InsufficientBalanceException $e) {
    // Handle lack of funds...
}
```

### 4. Transfer Between Wallets

[](#4-transfer-between-wallets)

```
$fromUser = User::find(1);
$toUser = User::find(2);

try {
    EasyWallet::transfer($fromUser, $toUser, 40.00, 'Transfer to friend');
} catch (\Exception $e) {
    // Handle error...
}
```

### 5. Get Wallet Balance

[](#5-get-wallet-balance)

```
$balance = EasyWallet::balance($user);
```

---

🎧 Events
--------

[](#-events)

The package fires events that you can listen to in your `EventServiceProvider`:

- `YasserElgammal\LaravelEasyWallet\Events\WalletCredited`
- `YasserElgammal\LaravelEasyWallet\Events\WalletDebited`
- `YasserElgammal\LaravelEasyWallet\Events\WalletTransferCompleted`

**Example Listener:**

```
use YasserElgammal\LaravelEasyWallet\Events\WalletCredited;

public function handle(WalletCredited $event)
{
    // Access transaction details:
    // $event->transaction->amount
    // Send email/notification to user...
}
```

---

⛏ Customization
---------------

[](#-customization)

### Change Prefix for Transaction Number

[](#change-prefix-for-transaction-number)

By default, it uses `TXN-{UUID}`. You can customize the prefix in your `.env` file:

```
WALLET_TXN_PREFIX=MY-PREFIX-
```

### Extending Package Models

[](#extending-package-models)

You can completely override the default `Wallet` and `WalletTransaction` models by publishing the config file and updating the class references.

```
php artisan vendor:publish --tag=easy-wallet-config
```

Then in `config/easy-wallet.php`:

```
'models' => [
    'wallet' => \App\Models\CustomWallet::class,
    'transaction' => \App\Models\CustomWalletTransaction::class,
],
```

🔧 Publishing Resources
----------------------

[](#-publishing-resources)

You can optionally publish resources to customize them:

### 1. Configuration File

[](#1-configuration-file)

```
php artisan vendor:publish --tag=easy-wallet-config
```

### 2. Migrations

[](#2-migrations)

```
php artisan vendor:publish --tag=easy-wallet-migrations
```

### 3. Models

[](#3-models)

```
php artisan vendor:publish --tag=easy-wallet-models
```

*(Remember to update the `config/easy-wallet.php` if you change the model namespaces!)*

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome and appreciated!

If you have an idea, feature request, bug fix, or any improvement:

- Feel free to open an issue.
- Submit a Pull Request.
- Or simply get in touch if you need help.

Thank you for supporting the project! 🙌

###  Health Score

42

↑

FairBetter than 88% of packages

Maintenance96

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Recently: every ~81 days

Total

7

Last Release

21d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35766609?v=4)[Yasser Elgammal](/maintainers/YasserElgammal)[@YasserElgammal](https://github.com/YasserElgammal)

---

Top Contributors

[![YasserElgammal](https://avatars.githubusercontent.com/u/35766609?v=4)](https://github.com/YasserElgammal "YasserElgammal (22 commits)")[![alihrhera](https://avatars.githubusercontent.com/u/15801976?v=4)](https://github.com/alihrhera "alihrhera (2 commits)")

---

Tags

financefintechlaravelmoney-managementphptransactionwallet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yasser-elgammal-laravel-easy-wallet/health.svg)

```
[![Health](https://phpackages.com/badges/yasser-elgammal-laravel-easy-wallet/health.svg)](https://phpackages.com/packages/yasser-elgammal-laravel-easy-wallet)
```

###  Alternatives

[lukaswhite/php-feed-writer

A PHP library for writing feeds; e.g. RSS

1030.1k1](/packages/lukaswhite-php-feed-writer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
