PHPackages                             roboticsexpert/balance-manager - 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. roboticsexpert/balance-manager

ActiveLibrary

roboticsexpert/balance-manager
==============================

Add balance (credit) for your users easily

v1.0.4(3y ago)32141MITPHP

Since Feb 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/roboticsexpert/balance-manager)[ Packagist](https://packagist.org/packages/roboticsexpert/balance-manager)[ RSS](/packages/roboticsexpert-balance-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

Laravel Balance manager
=======================

[](#laravel-balance-manager)

in many projects, you need to have credit (balance) concept for your user that make you distract from your main business logic.

with this package you will have balance for your users easily without being worry about `Race Condition`and `Double Spending`.

this project mainly designed for exchange systems, but you can use it in any project.

Installation
------------

[](#installation)

```
composer require roboticsexpert/balance-manager
```

after instaling composer package, if you use auto discovery for service providers, everything ok, but if you blocked that just add this line to `config/app.php` in `providers` section:

```
Roboticsexpert\BalanceManager\BalanceManagerServiceProvider::class
```

after that you should run

```
php artisan migrate
```

and this:

```
php artisan vendor:publish --provider="Roboticsexpert\BalanceManager\BalanceManagerServiceProvider"
```

it will create `balance.php` file in your config file.

Usage
-----

[](#usage)

First of all, you should decide with currencies you want to have in your system, and consider a KEY for each currency and add those keys in balance.php config file

```
return [

    // add symbols of your currencies
    // symbols must be lower than 16 char

    'currencies'=>[
        'BTC',
        'TMN',
        'DOGE',
    ]
];
```

you can use this project with 2 strategy,Facade or Dependency injection!

I suggest to you to use it with dependecy injection for IDE auto complete feature but use it as you prefer!

after that you can get `BalanceManager` from with these to methods:

### Facade

[](#facade)

you can get BalanceManager service like this:

```
use Roboticsexpert\BalanceManager\BalanceManagerFacade as BalanceManager;

BalanceManager::getAllBalancesByUserId(1)
```

### Dependency Injection

[](#dependency-injection)

you can get BalanceManager service from `app()` like this:

```
use Roboticsexpert\BalanceManager\Services\BalanceManager;

$balanceManager=app(BalanceManager::class);

$balanceManager->getAllBalancesByUserId(1);
```

or get from laravel automatic dependency injection

```
use Roboticsexpert\BalanceManager\Services\BalanceManager;
class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function index(BalanceManager $balanceManager){
        dd($balanceManager->getAllBalancesByUserId(1));
    }
}
```

Methods
-------

[](#methods)

### Get all balance for user

[](#get-all-balance-for-user)

it will return array of `Balance` model

```
$balances= $balanceManager->getAllBalancesByUserId("USER_ID");
dd($balances);
```

### Change balance of user

[](#change-balance-of-user)

```
$balanceChangeResult= $balanceManager->changeBalanceByUserIdAndCurrency(
        int $userId, //user id
        string $currency, // like USDT, TMN
        string $reason, // a unique string for each action
        IBalanceHistoryRelated $model, // a model that is author of change balance
        Decimal $valueChange, // value you want to add or sub from user balance
        Decimal $lockedValueChange // in general usage it should be new \Decimal\Decimal(0)
);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~105 days

Total

4

Last Release

1223d ago

### Community

Maintainers

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

---

Top Contributors

[![roboticsexpert](https://avatars.githubusercontent.com/u/9366277?v=4)](https://github.com/roboticsexpert "roboticsexpert (8 commits)")[![azibom](https://avatars.githubusercontent.com/u/34370960?v=4)](https://github.com/azibom "azibom (2 commits)")

---

Tags

balancecreditcryptocurrencydecimaldouble-spendinglaravelphprace-conditions

### Embed Badge

![Health badge](/badges/roboticsexpert-balance-manager/health.svg)

```
[![Health](https://phpackages.com/badges/roboticsexpert-balance-manager/health.svg)](https://phpackages.com/packages/roboticsexpert-balance-manager)
```

PHPackages © 2026

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