Skip to content
πŸŽ₯ πŸ“½ 🎞 Log your model changes in multiple ways
PHP
Branch: development
Clone or download
Latest commit 157ea00 Jan 16, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Apply fixes from StyleCI Jan 5, 2020
database/migrations
src Remove call to parent boot method, as it's now not overwritten Jan 15, 2020
tests Apply fixes from StyleCI Jan 5, 2020
.all-contributorsrc Update .all-contributorsrc Jan 16, 2020
.codecov.yml First commit Jan 1, 2020
.gitignore
.styleci.yml First commit Jan 1, 2020
.travis.yml First commit Jan 1, 2020
CONTRIBUTING.md Update CONTRIBUTING.md Jan 5, 2020
LICENSE.md First commit Jan 1, 2020
README.md docs: update README.md [skip ci] Jan 16, 2020
composer.json First commit Jan 1, 2020
photo.jpg Add files via upload Jan 5, 2020
phpunit.xml First commit Jan 1, 2020

README.md

Laravel Loggable - Log you model changes

Software License Total Downloads Packagist Version CodeFactor Grade

Laravel Loggable is a package for eloquent models, which will monitor the changes on the models and log. It suuports two drivers: File and Database.

Features

  • High-configurable
  • Two drivers (database and file)
  • Possibillity to use two drivers at once
  • Possibillity to select the columns for the model which should be logged
  • Possibillity to select the actions for the model which should be logged (create, edit, delete)
  • Facade-based structure to fetch the logs for specific model
  • Much more

Logs

Installation

Install the package.

composer require alkhachatryan/laravel-loggable

Publish the configuration file

php artisan vendor:publish --tag=loggable

Run migration

php artisan migrate

Configuration

Open the configuration file at /config/loggable.php

Set the driver whhich will log the model changes (can be both). However, it's recommended to use the database driver so you can fetch the logs in the future.

'driver' => 'database' 

That's it!

Usage

class Post extends Model
{
    /** Include the loggable trait */
    use Loggable;
    
    /** Specified actions for this model */
    public $loggable_actions = ['edit', 'create', 'delete'];

    /** Specified fields for this model */
    public $loggable_fields  = ['title', 'body'];

    protected $fillable = ['title', 'body'];
}
Retriving the model logs via Facade
Loggable::model('App\Post');
Retriving the model logs via Model
LoggableModel::whereModelName('App\Post')->orderBy('id', 'DESC')->paginate(10);
Event

You can use the event Alkhachatryan\LaravelLoggable\Events\Logged in pair with your listeners.

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits


Liam Hammett

Alexey

Todo

Tests!!! Tests!!! Tests!!!

Security

If you discover any security-related issues, please email info@khachatryan.org instead of using the issue tracker.

License

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

You can’t perform that action at this time.