Skip to content

Latest commit

 

History

History
93 lines (60 loc) · 2.65 KB

README.md

File metadata and controls

93 lines (60 loc) · 2.65 KB

A simple package to log model activities inside your laravel application

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package logs model activities inside your Laravel application.

Installation

You can install the package via composer:

composer require cybernerdie/laravel-model-activity-log

You can publish the migrations with:

php artisan vendor:publish --provider="Cybernerdie\\ModelActivityLog\\ModelActivityLogServiceProvider"

You can run the migrations with:

php artisan migrate

Usage

Add the trait to your model and also import the class:

use RecordModelActivity;

Optionally, you can set the events to be recorded for your model:

protected static $eventsToRecord = ['created', 'updated'];

Optionally, you can add columns in your model that you want to ignore when events are recorded:

 protected static $columnsToIgnore = ['email'];

Retrieve activities for a model:

$user = User::find(1);
$activities = ModelActivityLog::subjectBy($user)->get();

Retrieve activities by event type:

$activities = ModelActivityLog::event('created')->get();

Retrieve changes for a specific activity:

$activities = ModelActivityLog::find(1)->changes();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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