Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 2.01 KB

README.md

File metadata and controls

66 lines (45 loc) · 2.01 KB

Laravel Data Audit Package

GitHub Tests Action Status License

Installation

To install it you need to add this in your composer.json file

"repositories": {
        "eloise/laravel-data-audit": {        
            "type": "vcs",
            "url": "https://github.com/EloisePHP/laravel-data-audit-package"}
    },

and then

composer require eloise/laravel-data-audit

What It Does

This package allows you to audit every action done with a Model you chose.

Once installed for every Model in you project you want to Audit you should make it implement the contract AuditableModel and use the trait AuditableModelTrait like this:

class DefaultAuditableModel extends Model implements AuditableModel
{
    use AuditableModelTrait;

And that's it! Everytime someone creates, edits or deletes this model it will be audited and you can check it in the eloise_audit table.

Advanced Features

It has the feature of Rollback any auditable Model to the time of your choice, for example

$retrievesPost = Rollback::forModel($post)
                         ->atDate(Carbon::now()->subDay())
                         ->retrieve();

Or if you just want to see the first Post created

$retrievesPost = Rollback::forModel($post)
                         ->retrieve();

Support me

If you show this package to anyone out there it would help me a ton.

Testing

All tests are made with Orchestra Testbench.

Alternatives

  • Spatie Activity Log is a great package done by Spatie. The main difference with Spatie's package is that it is focused on user activity.

License

The MIT License (MIT). Please see License File for more information.