Download the PHP package sofa/laravel-history without Composer
On this page you can find all versions of the php package sofa/laravel-history. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-history
Eloquent History
No-setup history recording for your Eloquent models. Just install, migrate, and it works!
Roadmap (contributions most welcome 🙏🏼)
- [ ] retention configuration & command
- [ ] bundle frontend implementation to present history in a beautiful form blade
- [ ] bundle frontend implementation to present history in a beautiful form vue
- [ ] bundle frontend implementation to present history in a beautiful form TALL stack
- [ ] bundle frontend implementation to present history in a beautiful form react
Installation
You can install the package via composer:
Then publish migrations and config, then run migrations to create the necessary table:
This is the contents of the published config file:
Usage
Time travel with your models:
Get a full history/audit log of your models
You can easily create an Audit Log for your users too:
Additional setup & known limitations
The package offers 2 main functionalities:
- recording full history for a model
- recreating models with all relations in the past
History recording works out of the box for all your Eloquent models (really 😉). Additionally it will record and recreate model relations. There are however some limitations due to relations inner workings in Laravel:
- recreating
HasMany
,BelongsTo
,MorphTo
,MorphMany
&HasManyThrough
is fully supported out of the box -
recording and recreating many-to-many relations requires custom pivot model in order for Laravel to fire relevant events (
BelongsToMany
,MoprhToMany
). If you defined a custom pivot on your relation(s) already, you don't need to do anything. Otherwise, you can use provided placeholder pivot models: -
HasOne
relation can be recreated only when specific requirements are met: there is a singleorderBy(...)
on the relation definition and there are no complexwhere(...)
clauses (it does not affect recording history, just recreating model with relations):HasOneThrough
is currently not supported at all
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Jarek Tkaczyk
- All Contributors
License
The MIT License (MIT). Please see License File for more information.