- How do I install and set up Laravel Rewind for an Eloquent model?
- Run composer require avocet-shores/laravel-rewind, then publish the package config and migrations and run php artisan migrate. Add the Rewindable trait to the model you want to version and run php artisan rewind:add-version to add the required current_version column to that model's table. After that, normal create, update, and delete events are captured automatically and you can call rewind, fastForward, goTo, restore, and diff through the Rewind facade.
- Which Laravel versions does Laravel Rewind support?
- Rewind is built as a conventional Laravel package with a service provider, facade, publishable config, and migrations, so it fits normal Laravel application structure. The README excerpt does not list supported Laravel versions, so check the illuminate/support constraint in its composer.json and run the package test suite against your Laravel version before adopting. Pin the package version in composer.json so a pre-1.0 breaking change cannot surprise your deployment.
- How does the hybrid diff and snapshot storage in Laravel Rewind work?
- Rewind stores partial diffs between versions and writes a full snapshot every snapshot_interval versions, which defaults to 10. Diffs keep storage small while snapshots bound reconstruction cost, and a cost-based approach engine picks the fastest path when rebuilding a version. You can tune snapshot_interval for your storage and read-performance trade-off, and pruning converts the oldest remaining version into a snapshot so history stays navigable.
- What is the difference between goTo, rewind, fastForward, and restore in Laravel Rewind?
- rewind and fastForward move a model's version pointer one step backward or forward, while goTo jumps directly to a specific version. These navigation methods move the pointer without writing a new audit record. restore is different: it creates a brand-new version whose state is copied from the target version and records event_type restored, which makes it suitable for compliance-grade audit trails.
- How does Laravel Rewind handle concurrent writes and lock timeouts?
- Version sequence integrity relies on cache-based atomic locks, so correctness depends on your configured cache driver rather than only on your database. The on_lock_timeout behavior is configurable, and the default is log, which can silently drop a version write if a lock cannot be acquired. For audit-bearing models set it to throw or dispatch an event so a failed version write cannot pass unnoticed, and validate lock behavior in every deployment environment.
- Does Laravel Rewind capture bulk updates and saveQuietly() changes?
- No. Mass updates through Model::query()->update() and saveQuietly() bypass Eloquent model events, so Rewind will not create versions for those changes and your history will have silent gaps. Route auditable changes through normal model saves, or explicitly create versions around bulk operations. Test any bulk job against a versioned model before relying on Rewind for that data.
- How can I query an order or payment status timeline with Laravel Rewind?
- Declare the lifecycle attributes in $rewindStateFields on the model, then use whereStateBecame, whereStateTransition, and stateHistory to query version records. This gives you queryable point-in-time state and transition timelines without building bespoke history tables. It is the fastest path to demonstrable business value for order status, payment status, and similar state machines.
- Does Laravel Rewind support soft deletes, polymorphic models, and multi-tenant apps?
- The README does not document specific semantics for soft deletes, force deletes, polymorphic relations, or tenant scoping of current_version, so treat these as edges you must validate in your own application. Test deletion and restoration behavior, confirm cast fidelity for dates, enums, encrypted attributes, JSON columns, and custom casts, and decide whether current_version needs tenant scoping. If your models have these shapes, write integration tests before adopting.
- How do I backfill version history for existing rows in Laravel Rewind?
- There is an initVersion() method for initializing a model's version state, but the package does not document a bulk backfill command. For existing data, chunk through your rows and call initVersion() on each model inside a controlled job, watching lock timeouts and write amplification. Plan the backfill during a quiet window and verify reconstructed history on a sample before running it across the full table.
- Is Laravel Rewind production-ready at v0.9 for compliance auditing?
- The latest tagged release is v0.9.x, so semver permits breaking changes and every upgrade should be reviewed. It is a single-maintainer package with a small dependent ecosystem, so there is limited external validation and bus-factor risk, although the MIT license means you can fork if needed. For compliance use, harden the defaults, especially on_lock_timeout, test prune correctness on your model shapes, and budget for upgrade reviews. If those costs are acceptable, its hybrid storage and state-transition queries are a strong fit.