djunehor/laravel-revert-query

Log all model events and revert specific model event

1.0.0 2019-11-23 22:29 UTC

This package is auto-updated.

Last update: 2024-11-26 00:07:26 UTC


README

CircleCI Latest Stable Version Total Downloads License StyleCI Build Status Scrutinizer Code Quality Code Coverage

Laravel Model Event Logger and Revert logs every action on a model (create, delete, update), provides an interface to see the list of all activities as well as revert specific model event.

Installation

Step 1

You can install the package via composer:

composer require djunehor/laravel-revert-query

Laravel 5.5 and above

The package will automatically register itself, so you can start using it immediately.

Laravel 5.4 and older

In Laravel version 5.4 and older, you have to add the service provider in config/app.php file manually:

'providers' => [
    // ...
    Djunehor\EventRevert\EventRevertServiceProvider::class,
];

Lumen

After installing the package, you will have to register it in bootstrap/app.php file manually:

// Register Service Providers
    // ...
    $app->register(Djunehor\EventRevert\EventRevertServiceProvider::class);
];

Step 2 - Publishing files

  • Run: php artisan vendor:publish --tag=ModelEventLogger This will move the migration file, seeder file and config file to your app.
  • Open config/model-event-logger to set the model name and ID of users allowed to access to model event log routes
  • the ID can be a number or list of comma-separated numbers e.g 1,2,3,4,5

Step 3 - SetUp database

  • Runphp artisan migrate to create the table.

Usage

use Djunehor\EventRevert\ModelEventLogger;`
  • Add use ModelEventLogger to your laravel model

Access Saved model event logs

Reverting via Console

If you know the specific ID of the event you which you revert, you can run: php artisan model:revert --id=EVENT_ID

Contributing

  • Fork this project
  • Clone to your repo
  • Make your changes and run tests composer test
  • Push and create Pull Request