PHP Classes
elePHPant
Icontem

Laravel Revert Model Events: Log, list and undo changes done on model objects

Recommend this page to a friend!
  Info   View files Documentation   View files View files (27)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-11-30 (5 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 21 This week: 21All time: 9,755 This week: 10Up
Version License PHP version Categories
laravel-revert-model 1.0The PHP License5PHP 5, Databases, Libraries, Logging
Description Author

This package can be used to log, list and undo changes done on model objects.

It provides a service that can be registered to log events regarding changed performed on model objects of applications based on the Laravel framework.

The package can also provide access to let applications show the log of events, as well revert the changes done on the logged model objects.

Innovation Award
PHP Programming Innovation award nominee
November 2019
Nominee
Vote
Many applications use databases to store data of the objects that they need to manipulate.

Sometimes it would be good if it was possible to revert certain types of changes done to objects.

This package implements a solution that uses logging of model objects used in Laravel framework based applications to determine how to undo previously executed changes done to those model objects.

Manuel Lemos
  Performance   Level  
Name: Zacchaeus Bolaji <contact>
Classes: 6 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 1x

 

Details

Laravel Model Event Log & Revert

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

|Endpoint|Description| |:------------- | :----------: | |/model-events|return all saved model events| |/model-events/{log}|return all model events of a specific model| |/model-event-revert/{id}|revert specific model event|

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
  Files folder image Files  
File Role Description
Files folder image.circleci (1 file)
Files folder imagesrc (1 file, 8 directories)
Files folder imagetests (5 files, 1 directory)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .circleci  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageconfig (1 file)
Files folder imageConsole (1 directory)
Files folder imagedatabase (1 directory)
Files folder imageHelpers (1 file)
Files folder imageHttp (3 directories)
Files folder imageModels (1 file)
Files folder imageresources (2 directories)
Files folder imageroutes (1 file)
  Plain text file EventRevertServiceProvider.php Class Class source

  Files folder image Files  /  src  /  config  
File Role Description
  Accessible without login Plain text file model-event-logger.php Aux. Auxiliary script

  Files folder image Files  /  src  /  Console  
File Role Description
Files folder imageCommands (1 file)

  Files folder image Files  /  src  /  Console  /  Commands  
File Role Description
  Plain text file RevertModelEvent.php Class Class source

  Files folder image Files  /  src  /  database  
File Role Description
Files folder imagemigrations (1 file)

  Files folder image Files  /  src  /  database  /  migrations  
File Role Description
  Plain text file 2019_10_04_235130_...odel_logs_table.php Class Class source

  Files folder image Files  /  src  /  Helpers  
File Role Description
  Accessible without login Plain text file helpers.php Example Example script

  Files folder image Files  /  src  /  Http  
File Role Description
Files folder imageControllers (1 file)
Files folder imageMiddlewares (1 file)
Files folder imageTraits (1 file)

  Files folder image Files  /  src  /  Http  /  Controllers  
File Role Description
  Plain text file ModelLogController.php Class Class source

  Files folder image Files  /  src  /  Http  /  Middlewares  
File Role Description
  Plain text file ModelEventLogMiddleware.php Class Class source

  Files folder image Files  /  src  /  Http  /  Traits  
File Role Description
  Plain text file ModelEventLogger.php Class Class source

  Files folder image Files  /  src  /  Models  
File Role Description
  Plain text file ModelLog.php Class Class source

  Files folder image Files  /  src  /  resources  
File Role Description
Files folder imagelang (1 directory)
Files folder imageviews (3 files)

  Files folder image Files  /  src  /  resources  /  lang  
File Role Description
Files folder imageen (1 file)

  Files folder image Files  /  src  /  resources  /  lang  /  en  
File Role Description
  Accessible without login Plain text file model-event-logger.php Aux. Auxiliary script

  Files folder image Files  /  src  /  resources  /  views  
File Role Description
  Accessible without login Plain text file app.blade.php Aux. Auxiliary script
  Accessible without login Plain text file log-table.blade.php Example Example script
  Accessible without login Plain text file response.blade.php Aux. Auxiliary script

  Files folder image Files  /  src  /  routes  
File Role Description
  Accessible without login Plain text file web.php Aux. Auxiliary script

  Files folder image Files  /  tests  
File Role Description
Files folder imagemodels (2 files)
  Plain text file ModelEventCommandHelperTest.php Class Class source
  Plain text file ModelEventLogRevertClass.php Class Class source
  Plain text file ModelEventLogRouteTest.php Class Class source
  Plain text file ModelEventTest.php Class Class source
  Plain text file TestCase.php Class Class source

  Files folder image Files  /  tests  /  models  
File Role Description
  Plain text file ModelEventLogTestUser.php Class Class source
  Plain text file TestModel.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:21
This week:21
All time:9,755
This week:10Up