PHPackages                             walterjrp/laravel-wallet-mongodb - 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. walterjrp/laravel-wallet-mongodb

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

walterjrp/laravel-wallet-mongodb
================================

Easy work with virtual wallet.

4.1.0(6y ago)011MITPHPPHP ^7.2|^8.0

Since Nov 7Pushed 6y agoCompare

[ Source](https://github.com/walterjrp/laravel-wallet-mongodb)[ Packagist](https://packagist.org/packages/walterjrp/laravel-wallet-mongodb)[ Docs](https://bavix.github.io/laravel-wallet/)[ RSS](/packages/walterjrp-laravel-wallet-mongodb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (40)Used By (0)

[![Laravel Wallet](https://user-images.githubusercontent.com/5111255/48687709-a7c2fa00-ebd3-11e8-8714-c4f3efe93f02.png)](https://user-images.githubusercontent.com/5111255/48687709-a7c2fa00-ebd3-11e8-8714-c4f3efe93f02.png)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fde8a9c4176a64eea40dd14038d9f90fa77f51843d816c2b27b378f06b288389/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617669782f6c61726176656c2d77616c6c65742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bavix/laravel-wallet/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/13d91749e578074cffdc4441a452a08239a3005d4dafa572a22e905c505fffeb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617669782f6c61726176656c2d77616c6c65742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bavix/laravel-wallet/?branch=master)[![Build Status](https://camo.githubusercontent.com/d3d51aba2adea9670da6287713abb5acf95a8fb4b7821847633092668b838e97/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617669782f6c61726176656c2d77616c6c65742f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bavix/laravel-wallet/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/fa5452a395198fec33f2a0ddd1ca7dc9413469cecb486983be4555b199f08259/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617669782f6c61726176656c2d77616c6c65742f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Mutation testing badge](https://camo.githubusercontent.com/539d6f4fedad33ec1ecf50884a1649b92b9998c022871e6e438462bf8e32b5f0/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f62617669782f6c61726176656c2d77616c6c65742f6d6173746572)](https://packagist.org/packages/bavix/laravel-wallet)

[![Package Rank](https://camo.githubusercontent.com/40f1207a8445225febc80032460d45ca2e40e123ae06ccbdd06f534b686548b8/68747470733a2f2f7068707061636b616765732e6f72672f702f62617669782f6c61726176656c2d77616c6c65742f62616467652f72616e6b2e737667)](https://packagist.org/packages/bavix/laravel-wallet)[![Latest Stable Version](https://camo.githubusercontent.com/703e18ab4515ec8ea79e201ba9e1de5f4cdf2e5d99cde36d31361c7daf4db562/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f762f737461626c65)](https://packagist.org/packages/bavix/laravel-wallet)[![Latest Unstable Version](https://camo.githubusercontent.com/16905de8dc2edf3ec6223429da4be9937e9f6d2af3cb2b56ad12bafe675d15ea/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f762f756e737461626c65)](https://packagist.org/packages/bavix/laravel-wallet)[![License](https://camo.githubusercontent.com/6de443f6f31da5e3143cbe8c9536b1b3ed9978267ce792c57d05d738e59d3def/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f6c6963656e7365)](https://packagist.org/packages/bavix/laravel-wallet)[![composer.lock](https://camo.githubusercontent.com/9e96f0e03e71258c398eda14d460dd93dc0921392639aef41c855c4691425fa4/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f636f6d706f7365726c6f636b)](https://packagist.org/packages/bavix/laravel-wallet)

laravel-wallet - Easy work with virtual wallet.

\[[Documentation](https://bavix.github.io/laravel-wallet/)\] \[[Get Started](https://bavix.github.io/laravel-wallet/#/basic-usage)\]

\[[Документация](https://bavix.github.io/laravel-wallet/#/ru/)\] \[[Как начать](https://bavix.github.io/laravel-wallet/#/ru/basic-usage)\]

- **Vendor**: bavix
- **Package**: laravel-wallet
- **Version**: [![Latest Stable Version](https://camo.githubusercontent.com/703e18ab4515ec8ea79e201ba9e1de5f4cdf2e5d99cde36d31361c7daf4db562/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f762f737461626c65)](https://packagist.org/packages/bavix/laravel-wallet)
- **PHP Version**: 7.2+
- **Laravel Version**: `5.5`, `5.6`, `5.7`, `5.8`, `6.x`
- **[Composer](https://getcomposer.org/):** `composer require bavix/laravel-wallet`

### Upgrade Guide

[](#upgrade-guide)

To perform the migration, you will be [helped by the instruction](https://bavix.github.io/laravel-wallet/#/upgrade-guide).

### Extensions

[](#extensions)

ExtensionDescription[Swap](https://github.com/bavix/laravel-wallet-swap)Addition to the laravel-wallet library for quick setting of exchange rates[Vacuum](https://github.com/bavix/laravel-wallet-vacuum)Addition to the laravel-wallet library for quick fix race condition### Usage

[](#usage)

Add the `HasWallet` trait and `Wallet` interface to model.

```
use Bavix\Wallet\Traits\HasWallet;
use Bavix\Wallet\Interfaces\Wallet;

class User extends Model implements Wallet
{
    use HasWallet;
}
```

Now we make transactions.

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

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

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

$user->forceWithdraw(200, ['description' => 'payment of taxes']);
$user->balance; // int(-191)
```

### Purchases

[](#purchases)

Add the `CanPay` trait and `Customer` interface to your `User` model.

```
use Bavix\Wallet\Traits\CanPay;
use Bavix\Wallet\Interfaces\Customer;

class User extends Model implements Customer
{
    use CanPay;
}
```

Add the `HasWallet` trait and `Product` interface to `Item` model.

```
use Bavix\Wallet\Traits\HasWallet;
use Bavix\Wallet\Interfaces\Product;
use Bavix\Wallet\Interfaces\Customer;

class Item extends Model implements Product
{
    use HasWallet;

    public function canBuy(Customer $customer, int $quantity = 1, bool $force = null): bool
    {
        /**
         * If the service can be purchased once, then
         *  return !$customer->paid($this);
         */
        return true;
    }

    public function getAmountProduct(Customer $customer): int
    {
        return 100;
    }

    public function getMetaProduct(): ?array
    {
        return [
            'title' => $this->title,
            'description' => 'Purchase of Product #' . $this->id,
        ];
    }

    public function getUniqueId(): string
    {
        return (string)$this->getKey();
    }
}
```

Proceed to purchase.

```
$user = User::first();
$user->balance; // int(100)

$item = Item::first();
$user->pay($item); // If you do not have enough money, throw an exception
var_dump($user->balance); // int(0)

if ($user->safePay($item)) {
  // try to buy again )
}

var_dump((bool)$user->paid($item)); // bool(true)

var_dump($user->refund($item)); // bool(true)
var_dump((bool)$user->paid($item)); // bool(false)
```

### Eager Loading

[](#eager-loading)

```
User::with('wallet');
```

### How to work with fractional numbers?

[](#how-to-work-with-fractional-numbers)

Add the `HasWalletFloat` trait and `WalletFloat` interface to model.

```
use Bavix\Wallet\Traits\HasWalletFloat;
use Bavix\Wallet\Interfaces\WalletFloat;
use Bavix\Wallet\Interfaces\Wallet;

class User extends Model implements Wallet, WalletFloat
{
    use HasWalletFloat;
}
```

Now we make transactions.

```
$user = User::first();
$user->balance; // int(100)
$user->balanceFloat; // float(1.00)

$user->depositFloat(1.37);
$user->balance; // int(237)
$user->balanceFloat; // float(2.37)
```

---

Supported by

[![Supported by JetBrains](https://camo.githubusercontent.com/426b71c1485422e61c59d8b7fec03f4ba626dd77443847c0a14053491eb8fc4a/68747470733a2f2f63646e2e7261776769742e636f6d2f62617669782f646576656c6f706d656e742d7468726f7567682f34363437356234622f6a6574627261696e732e737667)](https://www.jetbrains.com/)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 94.8% 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 ~11 days

Recently: every ~24 days

Total

38

Last Release

2340d ago

Major Versions

0.0.1 → 1.0.02018-11-07

1.2.3 → 2.0.02018-11-21

2.4.1 → 3.0.02019-05-24

3.3.0 → 4.0.02019-10-04

PHP version history (3 changes)0.0.1PHP ^7.1

3.1.5PHP ^7.1|^8.0

4.0.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4810d055f2f7a1ab62c3007b4910c077e3f0beddeff2de6dce0fa5ce70c76e2?d=identicon)[junioraraujo](/maintainers/junioraraujo)

---

Top Contributors

[![rez1dent3](https://avatars.githubusercontent.com/u/5111255?v=4)](https://github.com/rez1dent3 "rez1dent3 (328 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (14 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (3 commits)")[![moecasts](https://avatars.githubusercontent.com/u/37169906?v=4)](https://github.com/moecasts "moecasts (1 commits)")

---

Tags

laravelcurrencypaymentslaravel5walletlaravel6virtualcreditslaravel-walletbavixlaravel5-packagelaravel6-package

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/walterjrp-laravel-wallet-mongodb/health.svg)

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

###  Alternatives

[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.1M11](/packages/bavix-laravel-wallet)[bavix/laravel-wallet-swap

Addition to the package laravel-wallet.

2427.2k](/packages/bavix-laravel-wallet-swap)[depsimon/laravel-wallet

Easy to use virtual wallet for your app

9521.6k1](/packages/depsimon-laravel-wallet)[misterphilip/maintenance-mode

An enhanced drop-in replacement for Laravel's maintenance mode

120176.7k](/packages/misterphilip-maintenance-mode)[brexis/laravel-workflow

Integerate Symfony Workflow component into Laravel.

283125.6k](/packages/brexis-laravel-workflow)[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

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