PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 31 All time: 11,095 This week: 455Up
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
Number 3
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
Picture of Zacchaeus Bolaji
  Performance   Level  
Name: Zacchaeus Bolaji <contact>
Classes: 17 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 245415 in Nigeria Nigeria
Week rank: 192 Up5 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Documentation

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

  • Run`php 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 (27)  
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 (27)  /  .circleci  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files (27)  /  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 (27)  /  src  /  config  
File Role Description
  Accessible without login Plain text file model-event-logger.php Aux. Auxiliary script

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

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

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

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

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

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

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

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

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

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

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

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

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

  Files folder image Files (27)  /  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 (27)  /  src  /  routes  
File Role Description
  Accessible without login Plain text file web.php Aux. Auxiliary script

  Files folder image Files (27)  /  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 (27)  /  tests  /  models  
File Role Description
  Plain text file ModelEventLogTestUser.php Class Class source
  Plain text file TestModel.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:31
This week:0
All time:11,095
This week:455Up