cybernerdie/laravel-model-activity-log

A simple package to log model activities inside your laravel application

1.0.2 2022-09-29 13:10 UTC

README

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.