NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Require the package. The service provider is auto-discovered, and its two Roundly dependencies — package-toolkit-for-laravel and money-for-laravel — install with it:

composer require roundly-consulting/credits-for-laravel

php artisan vendor:publish --tag="credits-migrations"
php artisan migrate

Publish-only migration

The package never loads its migration itself. Publishing copies the credits migration into your database/migrations, where you own it — so a bare php artisan migrate before publishing creates nothing. The file is stamped with the current time, so it runs after your own tables; publishing again overwrites that same file in place.

The migration creates two tables: credits, the ledger, and credit_locks, one small row per owner that serialises concurrent changes (see Overdraft protection).

If your creditable models use UUID or ULID keys, set CREDITS_KEY_TYPE before you migrate — see Key types & schema.

A forward-only migration

Like every Roundly package migration, it has no down(): php artisan migrate:rollback does not drop the two tables, and the next migrate then fails on “table already exists”. The published copy is yours — to uninstall, drop credits and credit_locks in a migration of your own, or add a down() to your copy.

Config and translations

The config file is optional — the package works with zero host configuration. Publish it only to override a default:

php artisan vendor:publish --tag="credits-config"

The exception messages are translatable. Publish them to lang/vendor/credits to edit or add locales:

php artisan vendor:publish --tag="credits-translations"

The package exposes exactly three publish tags: credits-migrations, credits-config and credits-translations.

Next steps

  • Add the Creditable interface and the HasCredits trait to a model.
  • Grant and deduct credits with modifyCredits().
  • Split credit into named buckets if different kinds must never be spent against each other.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.