tectiv3 / loggable by tectiv3
forked from themightysapien/loggable

:This packages allows the laravel models to have automatic logging
6
0
1
Package Data
Maintainer Username: tectiv3
Package Create Date: 2016-09-29
Package Last Update: 2019-02-07
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:24:21
Package Statistics
Total Downloads: 6
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

loggable

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.