Open sourceLaravel package
Laravel Credits
Laravel Credits is an open-source Laravel package by Climactic that gives any Eloquent model a credit ledger with a running balance. It is made for virtual currencies, reward points and usage credits.
Install
composer require climactic/laravel-credits
php artisan vendor:publish --tag="credits-migrations"
php artisan migrate- Type
- Laravel package
- Requires
- PHP 8.4 or later, Laravel 12 or 13
- License
- MIT
- Maintained by
- Climactic
- Runs in
- Markdown Anything, ColorBuk
What it does
- Add, deduct, transfer
- One trait gives a model methods to add and deduct credits and to transfer them to another model.
- A real ledger
- Every change is a transaction with a running balance, so you can show a history or audit an account.
- Balance at any date
- Look up what a balance was at a point in the past.
- Metadata on every transaction
- Attach JSON metadata and query it with scopes such as whereMetadata and whereMetadataContains.
- Safe under load
- Row-level locking prevents race conditions when two requests change one balance at the same time.
- Events
- CreditsAdded, CreditsDeducted and CreditsTransferred fire so the rest of your app can react.
Example
Add credits, deduct them and check a balance.
// Add credits
$user->creditAdd(100.00, 'Subscription Activated');
// Deduct credits
$user->creditDeduct(50.00, 'Purchase Made');
// Get current balance
$balance = $user->creditBalance();
// Check if user has enough credits
if ($user->hasCredits(30.00)) {
// Proceed with transaction
}- Use MySQL, MariaDB or PostgreSQL in production. SQLite ignores row-level locking.
- This package is not affiliated with Laravel. Laravel is a trademark of Taylor Otwell.
Questions about Laravel Credits
What is Laravel Credits?
Laravel Credits is an open-source Laravel package by Climactic that gives any Eloquent model a credit ledger with a running balance. It is made for virtual currencies, reward points and usage credits.
How do I install Laravel Credits?
Run "composer require climactic/laravel-credits". It needs PHP 8.4 or later, Laravel 12 or 13.
Is Laravel Credits free to use?
Yes. Laravel Credits is open source under the MIT license, and the source code is on GitHub at github.com/Climactic/laravel-credits.
Is Laravel Credits used in production?
Yes. Laravel Credits runs in production in Markdown Anything and ColorBuk, products that Climactic builds and operates.
Who maintains Laravel Credits?
Climactic, a venture studio that builds and operates its own software products, maintains Laravel Credits.
More open source from Climactic
- veer Inertia.js server adapter for Rust. Return typed props from axum handlers and render React, Vue or Svelte pages.
- laravel-spam Block spam signups in Laravel with disposable-email, blocklist and StopForumSpam checks.
- laravel-altcha Drop-in Laravel integration for ALTCHA, a privacy-friendly, self-hosted alternative to CAPTCHA.
- laravel-polar Laravel SDK for Polar.sh. Adds subscriptions, one-time payments, and license keys to a Laravel app. Runs in Markdown Anything and ColorBuk
- pixelserve Self-hosted image proxy and transformer. Resize, crop, and reformat images on demand, and generate Open Graph images. Runs in Markdown Anything and ColorBuk