PHPackages                             chapdel/credits - 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. chapdel/credits

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

chapdel/credits
===============

A credit system for Laravel.

1.1(1y ago)0248MITPHPPHP ^8.4

Since Mar 22Pushed 1y agoCompare

[ Source](https://github.com/chapdel/laravel-balance)[ Packagist](https://packagist.org/packages/chapdel/credits)[ Docs](https://github.com/chapdel/credits)[ RSS](/packages/chapdel-credits/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Add a balance / credit system to any Laravel model
==================================================

[](#add-a-balance--credit-system-to-any-laravel-model)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2b042f7b8f8b1026a732cd356b27ccce903a4aa10e8ae26de8ce322064179922/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656f777267657475646f722f6c61726176656c2d62616c616e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/geowrgetudor/laravel-balance)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cf97030f49fd4d4e2c99b9f6aa312404865a74fd099366b06aef0bd35b36c4e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f67656f777267657475646f722f6c61726176656c2d62616c616e63652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/geowrgetudor/laravel-balance/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e0323ac188d36f7e8fde91d49214a09ea26eb29b743d31c4634835d21ad4021d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f67656f777267657475646f722f6c61726176656c2d62616c616e63652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/geowrgetudor/laravel-balance/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b4d282f210b184543943d4fb97de51d1079b841531ae8da5b7ee8fc660f0dbf6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67656f777267657475646f722f6c61726176656c2d62616c616e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/geowrgetudor/laravel-balance)

This is a small package that adds a credit system that you might need for various reasons:

- awarding users based on their activity
- rewards in credits instead of real money
- rewards in credits for referrals
- etc.

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

[](#installation)

Install the package via composer:

```
composer require geowrgetudor/laravel-balance
```

Publish and run the migrations with:

```
php artisan vendor:publish --tag="balance-migrations"
php artisan migrate
```

If you decide to change the default migration table name, make sure you publish the config file and change the table name there too:

```
php artisan vendor:publish --tag="balance-config"
```

This is the contents of the published config file:

```
return [
    /**
     * Default table name.
     * If you have changed the migration, make sure you change this too.
     */
    'table' => 'balances',
    'default_currency' => 'EUR', // Default Currency
];
```

Prepare your model
------------------

[](#prepare-your-model)

Add the `HasBalance` trait to any model you need to.

```
use Geow\Balance\Traits\HasBalance;

class User extends Model {
    // ...
    use HasBalance;

}
```

Usage
-----

[](#usage)

```
// Set balance (similar to increaseCredit() method - just a naming difference)
$user->setCredit(2000);

// Get balance
$user->credit;

// Increase balance
$user->increaseCredit(1000);

// Decrease balance
$user->decreaseCredit(500);

// Reset balance to 0
$user->resetCredit();

// Check if the user has balance
$user->hasCredit();

// Passing a reason for setting/increasing/deacreasing the balance
$user->setCredit(20000, 'Signup bonus');
$user->increaseCredit(1000, 'Awarded credits');
$user->decreaseCredit(250, 'Service usage');

// Get balance as currency
$user->increaseCredit(1000);
$user->credit; // returns 1000 (represeting cents)
$user->creditCurrency; // returns $10.00 (representing dollars)

// If you need to display using a different currency
$user->withCurrency('EUR')->creditCurrency // returns €10.00

// Getting all model related transactions (increases and decresed in balance)
$user->credits; // Returns \Illuminate\Database\Eloquent\Collection
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [George Tudor](https://github.com/geowrgetudor)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance46

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~6 days

Total

2

Last Release

414d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20987014?v=4)[Chapdel KAMGA](/maintainers/chapdel)[@chapdel](https://github.com/chapdel)

---

Top Contributors

[![geowrgetudor](https://avatars.githubusercontent.com/u/7842657?v=4)](https://github.com/geowrgetudor "geowrgetudor (11 commits)")[![chapdel](https://avatars.githubusercontent.com/u/20987014?v=4)](https://github.com/chapdel "chapdel (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")[![dceleste35](https://avatars.githubusercontent.com/u/145990752?v=4)](https://github.com/dceleste35 "dceleste35 (1 commits)")[![ismailcaakir](https://avatars.githubusercontent.com/u/8665190?v=4)](https://github.com/ismailcaakir "ismailcaakir (1 commits)")[![Luan1Schons](https://avatars.githubusercontent.com/u/52085622?v=4)](https://github.com/Luan1Schons "Luan1Schons (1 commits)")

---

Tags

laravelbalancecredit-system

### Embed Badge

![Health badge](/badges/chapdel-credits/health.svg)

```
[![Health](https://phpackages.com/badges/chapdel-credits/health.svg)](https://phpackages.com/packages/chapdel-credits)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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