tpenaranda/model-log

A Laravel 5 package to automatically log attributes changes on any of your app models.

0.2.0 2018-01-03 21:15 UTC

README

A Laravel 5 package to automatically log attributes changes on any of your app models.

About package

This package is intended for tracking changes of your Eloquent models inside your Laravel application. A new DB table will be created and everytime a model attribute is updated an entry will be automatically created on the DB log table.

Installation

Require this package in your composer.json

$ composer require tpenaranda/model-log

Run artisan command to generate the migration for the new log table.

$ php artisan model-log:create-log-table

Add trait and specify attributes you want to observe/track for changes.

class MyModel extends Model
{
    use \EnableModelLog;

    protected $log = ['my_attribute', 'track_this_column_too'];
}

Usage

Retrieve log entries:

    $my_model->logEntries;