- How do I install mreduar/laravel-balance in a Laravel application?
- Install it with Composer using composer require mreduar/laravel-balance, then follow the package README for any service provider, config publishing, or migration steps. Laravel package discovery may register the service provider automatically, but you should confirm the exact integration points in the package source. Run your migrations and application test suite in a sandbox branch before deploying. Check composer.json for the supported Laravel and PHP constraints.
- Which Laravel and PHP versions are supported by laravel-balance?
- Version 1.4.0 added support for the latest Laravel versions, but the release note does not publish a complete Laravel and PHP support matrix. You should inspect the package composer.json, README, changelog, and CI configuration to confirm current constraints. Do not assume that support for the latest Laravel release means your specific Laravel or PHP version is supported. Verify the matrix before adopting or upgrading.
- Will mreduar/laravel-balance work with older Laravel versions?
- The v1.4.0 release is described as adding support for the latest Laravel versions, which can also mean older Laravel or PHP versions were dropped. The release notes do not state whether Composer constraints changed, so compare the package constraints against your lockfile. If you are on an older Laravel release, confirm compatibility in a non-production branch before upgrading. Run your application tests and targeted balance checks in staging.
- How do I increase or decrease a model's balance with laravel-balance?
- The package exposes an expressive API for crediting and debiting Eloquent models, including increase and decrease operations. Balance changes are stored as movements so you retain a transaction history. Check the README for the exact method names and return values before wiring it into your domain logic. Validate behavior with tests around positive, zero, and insufficient balance scenarios.
- Does laravel-balance keep a full transaction history of balance movements?
- Yes. The package is designed to maintain a history of balance movements in your Eloquent models. That gives you an auditable record of credits, debits, resets, and balance sets instead of only storing a current total. You should still review how the history table is structured and whether it meets your audit or reporting requirements. Confirm retention and indexing needs for high-volume usage.
- Are balance updates in mreduar/laravel-balance atomic and race-safe?
- The package blurb advertises atomic, race-safe updates, which is important when multiple requests credit or debit the same model. Atomicity depends on the underlying database operations, transactions, and locking strategy, so review the source and test concurrent updates. Run a load or concurrency test against your database engine before using it for high-volume financial-style balances. Do not rely on the marketing description alone for production guarantees.
- How can I check if a model has a positive balance or no balance?
- The package provides checks for whether a model has a positive balance or no balance, in addition to setting and resetting balances. Review the README for the exact query methods and how they behave for zero, positive, and missing balance records. Add tests for edge cases such as a newly created model with no movements. Confirm whether the checks query the current balance or recalculate from history.
- Can I reset or manually set a model's balance using laravel-balance?
- Yes. The package supports resetting and setting a model's balance in addition to increasing and decreasing it. Manual sets are useful for corrections, migrations, or reconciliation jobs, but you should confirm whether those operations also create history records. Keep an audit trail if your application requires explainable balance changes. Test reset and set behavior against your existing data before rollout.
- Is mreduar/laravel-balance actively maintained and safe for production?
- It is a community Laravel package, and v1.4.0 is a compatibility maintenance release rather than a major feature release. That is a positive maintenance signal, but it does not prove long-term support or a complete CI matrix. Review release cadence, test coverage, license, and maintainer responsiveness before adopting it. Treat adoption as low-to-moderate risk and validate it in a sandbox and staging environment.
- What are alternatives to mreduar/laravel-balance for tracking balances in Laravel?
- Alternatives include building a small ledger table and service class yourself, using a broader Laravel wallet or accounting package, or applying event sourcing for complex financial domains. This package is a lightweight fit when you mainly need credit, debit, reset, set, and positive-or-zero balance checks on Eloquent models. Compare alternatives on atomicity, audit history, database support, and maintenance activity. For regulated or high-volume money movement, require stronger transactional guarantees and testing.