climactic/laravel-credits
Ledger-based credits for Laravel: manage virtual currencies, reward points, and other credit systems with deposits, withdrawals, transfers, transaction history, historical balances, and metadata-powered querying.
HasCredits) and basic configuration.CreditTestCase trait).composer require climactic/laravel-credits
php artisan vendor:publish --tag="credits-migrations"
php artisan vendor:publish --tag="credits-config"
php artisan migrate
HasCredits trait to relevant models (e.g., User, Customer).class User extends Model {
use HasCredits;
}
config/credits.php for allow_negative_balance and table names.CreditTestCase trait or write custom tests for business logic.creditAdd, creditDeduct, creditTransfer).credits.added, credits.deducted, credits.transferred for observability.HasCredits methods).limit, offset) recommended for large datasets.credits table growth and query performance (e.g., slow metadata queries).| Scenario | Risk | Mitigation |
|---|---|---|
| Concurrent transactions | Race conditions (SQLite) | Use MySQL/PostgreSQL; add retry logic. |
| Metadata query timeouts | Unindexed queries on large tables | Preemptively add indexes; monitor query plans. |
| Negative balances | Business logic errors | Enable allow_negative_balance if needed. |
| Migration failures | Downtime during schema changes | Run migrations during low-traffic periods. |
| Event listener failures | Lost business logic | Implement dead-letter queues for events. |
How can I help you explore Laravel packages today?