Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Credits

Laravel Credits Laravel Package

climactic/laravel-credits

Ledger-based credit system for Laravel: manage virtual currencies, reward points, and balances with deposits, withdrawals, transfers, transaction history, historical balance checks, and metadata support. Ideal for credit-based features in any app.

View on GitHub
Deep Wiki
Context7

A ledger-based Laravel package for managing credit-based systems in your application.

Frequently asked questions about Laravel Credits
How do I install climactic/laravel-credits in a Laravel project?
Run `composer require climactic/laravel-credits`, then publish the migrations and config with `php artisan vendor:publish --tag=credits-migrations` and `php artisan vendor:publish --tag=credits-config`. Finally, execute `php artisan migrate` to set up the database tables. The package supports Laravel 8+.
Which Laravel versions are officially supported?
The package is tested and compatible with Laravel 8 and above. It is actively maintained and updated for newer Laravel releases, with the latest tests covering up to Laravel 10.x. Always check the GitHub repo for version-specific notes.
Can I use this for a loyalty program with reward points?
Yes, Laravel Credits is ideal for loyalty programs. It supports deposits (earning points), withdrawals (redeeming points), transfers (moving points between users), and metadata to track sources like purchases or referrals. The ledger ensures accurate balance tracking.
How does concurrency safety work for high-traffic apps?
The package uses row-level locking (`SELECT FOR UPDATE`) to prevent race conditions during credit operations. For production, use MySQL (InnoDB) or PostgreSQL, as SQLite lacks concurrency guarantees. Ensure your database isolation level is set to `READ COMMITTED` or higher.
What if I need to query transactions by metadata (e.g., source = 'promotion')?
You can query transactions by metadata using `whereMetadata()` or `whereMetadataLike()`. For large datasets, optimize performance by adding database indexes (e.g., virtual columns in MySQL or GIN indexes in PostgreSQL) on frequently queried metadata fields.
Does Laravel Credits support negative balances? How do I configure it?
Negative balances are disabled by default (`allow_negative_balance = false`). To enable them, set `allow_negative_balance = true` in `config/credits.php`. However, consider adding application-level validation to prevent unintended overdrafts.
How do I integrate credit events (e.g., CreditsAdded) with notifications?
Laravel Credits dispatches events like `CreditsAdded` and `CreditsDeducted`. Listen to these events in your `EventServiceProvider` or use Laravel’s event system to trigger notifications, analytics, or other actions. Example: `event(new CreditsAdded($user, $amount));`
What database should I use for production? SQLite or MySQL/PostgreSQL?
For production, use MySQL (InnoDB) or PostgreSQL for concurrency safety and performance. SQLite is not recommended for high-traffic environments due to its lack of row-level locking. The package works with all three, but SQLite may cause race conditions under load.
How do I add credits to a user’s wallet programmatically?
Use the `deposit()` method on a model with the `HasCredits` trait. Example: `$user->deposit(100, ['source' => 'signup_bonus']);` This creates a transaction with metadata and updates the user’s balance. You can also chain methods like `deposit()->withMetadata(['campaign' => 'summer'])`.
Are there alternatives to Laravel Credits for credit systems?
Alternatives include `spatie/laravel-activitylog` (for general auditing), `cartalyst/sentinel` (for user-based credits), or custom solutions using Laravel’s Eloquent events. However, Laravel Credits is specialized for ledger-based systems with built-in balance tracking, transfers, and metadata support, making it more feature-complete for credit-driven apps.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle