tectiv3/loggable

:This packages allows the laravel models to have automatic logging

dev-master 2019-02-07 02:49 UTC

This package is auto-updated.

Last update: 2024-12-07 16:09:33 UTC


README

Loggable is a Laravel 5 package which helps users to keep simple log of their model CRUD operations. .

Installation

$ composer require tectiv3/loggable
  • Add the service provider to the providers array in app.php
tectiv3\Loggable\ServiceProvider::class

//Then do vendor:publish from the artisan command to copy the migration file and run migrate command
php artisan vendor:publish --provider="tectiv3\Loggable\ServiceProvider"
php artisan migrate

Usage

//use Loggable in any of your models whose CRUD logs you want to keep
use tectiv3\Loggable\Loggable;
class DemoModel extends \Eloquent {
    use Loggable;
}

//for all logs loop through \tectiv3\Loggable\Log::all() or filter it however you like

//for model specific logs you can call $model->logs to get model specific logs

//then inside the loop you can access the user with ->user property

foreach($model->logs as $log){
    echo $log->entity . ' || ' . $log->action;
    echo '<br>';
    echo 'By :'.$log->user->name.' at '.$log->created_at;
}

Credits

License

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