Package that makes it easy to log any changes for your models.
alzpk/laravel-change-log is a Laravel package for package that makes it easy to log any changes for your models..
It currently has 0 GitHub stars and 4 downloads on Packagist (latest version v0.1.0).
Install it with composer require alzpk/laravel-change-log.
Discover more Laravel packages by alzpk
or browse all Laravel packages to compare alternatives.
Last updated
Package that makes it easy to log any changes for your models. The package uses Laravel's Model Events to log the changes. It will log the changes to the changes relation of the model, when ever a model is created, updated, or deleted.
The package will allow you to revert the latest changes, or revert changes by id, depending on the action.
composer require alzpk/laravel-change-log
php artisan vendor:publish --provider="Alzpk\LaravelChangeLog\ChangeLogServiceProvider"
php artisan migrate
To use the package, add the trait to the models you want to log:
use Alzpk\LaravelChangeLog\Models\Traits\HasChangeLog;
Here are some examples of how to use the package.
Bellow is an example of how to use the package inside your model.
namespace App\Models;
use Alzpk\LaravelChangeLog\Models\Traits\HasChangeLog;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use HasChangeLog;
}
Bellow is an example of how to use the show changes method.
$product = Product::first();
$product->changes->each(function ($change) {
dump($change);
});
Bellow is an example of how to use the revert latest changes method.
$product = Product::first();
$product->revertLatestChanges();
Bellow is an example of how to use the revert changes by id method.
$product = Product::first();
$change = $product->changes->first();
$product->revertChangesById($change->id);