- How do I install appstract/laravel-stock in a Laravel application?
- Install it with Composer using composer require appstract/laravel-stock, then publish and run the package migrations so the required stock columns or table exist. Add the package trait to the Eloquent models that need inventory counters and call the increment, decrement, and read methods it provides. Validate the install on a non-critical model first and confirm the generated schema matches your database conventions.
- Which Laravel and PHP versions does appstract/laravel-stock support?
- The last tagged release was 2021-05-14, so compatibility with current Laravel and PHP versions is not guaranteed. Check the package composer.json constraints and run composer why-not against your target Laravel and PHP matrix before adopting it. If the constraints block your stack, plan to fork and widen them rather than assuming upstream will publish an update.
- How do I add stock tracking to an Eloquent model with laravel-stock?
- Add the package trait to an Eloquent model, then use its stock methods to increase, decrease, or read the available quantity. Keep controllers thin by wrapping those calls in your own inventory service so the package stays an implementation detail. Test increments and decrements inside a transaction on a low-risk model before wiring the trait into order or checkout flows.
- Is appstract/laravel-stock safe for concurrent stock decrements in production?
- The technical evaluation flags concurrency as an open risk: verify whether updates use atomic SQL expressions or a read-modify-write pattern. Wrap decrements in database transactions and check for row locking such as lockForUpdate or conditional updates that keep quantity from going negative. Add race-condition tests with parallel decrements before trusting it on revenue-critical stock paths.
- Does appstract/laravel-stock keep a stock movement or audit history?
- The package is described as a lightweight stock counter, and the evaluation notes there is no stock movement ledger or audit table. If you need an auditable history of every change, record mutations in your own table or log alongside the package calls. Do not assume it provides traceability for regulated or financial inventory requirements.
- Can laravel-stock handle multiple warehouses or stock locations?
- No, it is positioned for simple model-level stock counters rather than multi-warehouse allocation or location-level fulfillment. The schema does not appear to model warehouses, transfers, or per-location availability. If you need those capabilities, build an application-owned inventory layer and treat the package as one replaceable detail.
- How do I check the available stock quantity for a model with laravel-stock?
- Use the package read or available-quantity method on the trait-enabled model to fetch the current stock level before allowing a purchase or allocation. Re-check the quantity inside the same transaction that performs the decrement to avoid overselling between read and write. If you need fast storefront reads, cache display values separately from the authoritative counter.
- Is appstract/laravel-stock still maintained, and what happens if it is abandoned?
- The last release was in May 2021, and the package is MIT licensed with a modest star count, so it is forkable but not vendor-supported. Pin the version, monitor compatibility with Laravel and PHP upgrades, and keep an internal fork option ready. Wrapping it behind an interface means replacing or forking it will not require touching domain code.
- Can I use appstract/laravel-stock for backorders, reservations, or negative stock?
- The package targets straightforward on-hand counters, and the evaluation notes reservations, backorders, and negative stock policies are outside its scope. Implement those rules in your application layer or choose a fuller inventory package for complex fulfillment. Verify how decrements behave at zero before committing to a negative stock policy.
- How should I test stock changes and race conditions when using laravel-stock?
- Write feature tests covering increments, decrements, reads, and transaction rollback behavior on the trait-enabled model. Add concurrency tests using parallel processes or multiple database connections to detect stock drift from non-atomic updates. Also test migration rollback and stock backfill reconciliation before any production cutover.