Download the PHP package fico7489/laravel-revisionable-upgrade without Composer
On this page you can find all versions of the php package fico7489/laravel-revisionable-upgrade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fico7489/laravel-revisionable-upgrade
More information about fico7489/laravel-revisionable-upgrade
Files in fico7489/laravel-revisionable-upgrade
Package laravel-revisionable-upgrade
Short Description Upgrade for the venturecraft revisionable package, add many useful methods.
License MIT
Homepage https://github.com/fico7489/laravel-revisionable-upgrade
Informations about the package laravel-revisionable-upgrade
Laravel revisionable upgrade
Upgrade for the Venturecraft Revisionable package, many useful methods are added.
Why to use
Yeah, revisionable package has userResponsible () method, but that is not enough and we can use saved revisions for much more useful stuff. We can find out who created, deleted and edited model, when the model was edited, when exact attribute from the model was edited and much more.
- You don't need to add updated_by, deleted_by, created_by to your tables.
- You don't need to add updated_attribute_by to your tables.
- You don't need to add updated_attribute_to_value_by to your tables.
- You don't need to add updated_attribute_from_value_to_value_by to your tables.
- You don't need to add updated_attribute_at to your tables.
- You don't need to add updated_attribute_to_value_at to your tables.
- You don't need to add updated_attribute_from_value_to_value_at to your tables.
- You don't need author_id, created_user_id, deleted_user_id etc. or anything like that
Don't pollute your tables with above table columns in the database, all above information is already stored in revisions table we just need the ability to get them, and this package will help you with that.
Version Compatibility
The package is available for larvel 5.* versions
Install
1.Install package with composer
2.Use Fico7489\Laravel\RevisionableUpgrade\Traits\RevisionableUpgradeTrait trait in your base model or only in particular models. Model which use RevisionableUpgradeTrait must also use RevisionableTrait;
and that's it, you are ready to go.
New methods
- userCreated() Returns user which created this model
- userDeleted() Returns user which deleted this model
-
userUpdated($key = null, $newValue = null, $oldValue = null) Returns user which updated this model (last user if there are more)
- revisionCreated() Returns revision for model created
- revisionDeleted() Returns revision for model deleted
-
revisionUpdated($key = null, $newValue = null, $oldValue = null) Returns revision for model updated (last revision if there are more)
- dateUpdated($key = null, $newValue = null, $oldValue = null) Returns date(Carbon\Carbon) for model updated (last revision if there are more)
- revisionsUpdated($key = null, $newValue = null, $oldValue = null) Returns revisions for model updated
- usersUpdated($key = null, $newValue = null, $oldValue = null) Returns users for model updated
Clarification for methods with ($key = null, $newValue = null, $oldValue = null)
- All parameters are optional
- If you provide $key method will look for changes on that key/field
- If you provide $newValue method will look for changes where key/field is changed to this value
- If you provide $oldValue method will look for changes where key/field is changed from this value
We don't need dateCreated and dateDeleted because information about this is stored in created_at and deleted_at. We don't need revisionsCreated, revisionsDeleted, usersCreated, usersDeleted because model can be created or deleted only once. Methods which returns user and users are using model from auth.model configuration.
See some action
Improtant notes
Models where you want use this package must use created_at timestamp
If you want fetch users that have deleted models you must enable $revisionCreationsEnabled
License
MIT
Free Software, Hell Yeah!