- What is owen-it/spark-auditing used for?
- owen-it/spark-auditing is an audit trail package for Laravel Spark that automatically records Eloquent model changes, including creates, updates, and deletes. It helps you track who changed what and when inside a Spark application. The package is designed to integrate with Spark and Laravel's model event and auditing workflows.
- How do I install owen-it/spark-auditing in a Laravel Spark application?
- Install the package with Composer using composer require owen-it/spark-auditing. Then follow the package setup steps to publish any configuration and database migrations needed for the audit table. Run the migrations and add the auditing trait or contract to the Eloquent models you want to track.
- Which Laravel and Spark versions does spark-auditing support?
- Supported versions are defined by the package's Composer constraints, so check its composer.json and release notes for the exact Laravel and Spark versions. Because the package targets Laravel Spark, its constraints generally follow the Spark release you are using. If your application is on an unsupported version, pin a compatible release or evaluate the broader owen-it/laravel-auditing package.
- How does spark-auditing know who changed a model?
- The package records audit entries when Eloquent model events fire and can capture the currently authenticated user from Laravel Spark's authentication context. That user identifier is stored with the audit record so you can see who performed each create, update, or delete. For console commands or queued jobs, the user may be null unless you explicitly set an audit user.
- Can I limit auditing to specific models or attributes?
- Yes, auditing is typically enabled per model by applying the package's auditable trait or contract rather than globally auditing every Eloquent model. You can also configure which attributes are included or excluded so sensitive fields are not written to the audit trail. Check the package configuration for the exact model and attribute options available in your version.
- Does spark-auditing log deletes as well as creates and updates?
- The package is built around Eloquent create, update, and delete events, so normal model deletions are recorded as audit entries. Behavior for restore, forceDelete, and other custom events depends on the package version and configuration. Confirm those edge cases in the documentation or by testing against your Spark application.
- How do I test that audit trails work in a Laravel Spark app?
- Write a feature test that creates, updates, or deletes an auditable model while acting as an authenticated Spark user. Then assert that the expected audit record exists with the correct event, user identifier, and old or new values. Use Laravel's database testing helpers and a clean test database so audit rows do not leak between tests.
- Will spark-auditing slow down my production application?
- Auditing adds database writes each time an audited model is created, updated, or deleted, so write-heavy applications may see some overhead. Keep the audit table indexed, avoid auditing unnecessary models or large attributes, and review whether your version supports queued or custom audit drivers. Test under realistic load before enabling it broadly in production.
- What is the difference between owen-it/spark-auditing and owen-it/laravel-auditing?
- owen-it/spark-auditing is tailored for Laravel Spark applications, while owen-it/laravel-auditing is the more general Laravel auditing package. The Spark package focuses on integrating audit trails with Spark's application structure and authentication context. If you are not using Spark, the general laravel-auditing package is usually the more appropriate starting point.
- How do I handle maintenance or compatibility issues with spark-auditing?
- Check the GitHub repository for recent releases, open issues, and compatibility notes before upgrading Laravel or Spark. Pin the package to a tested version in composer.json and review changelogs when updating. If the package lags behind your framework version, you can fork it, contribute a compatibility fix, or migrate to the general owen-it/laravel-auditing package.