scolib/laravel-action-log

A laravel package for logging user actions into the database

v1.3.1 2017-09-12 12:57 UTC

This package is auto-updated.

Last update: 2021-09-29 01:39:12 UTC


README

StyleCI Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Install

Laravel 5.5.*

$ composer require scolib/laravel-action-log:1.3.*

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Laravel 5.4.*

$ composer require scolib/laravel-action-log:1.2.*

Add the ServiceProvider to the providers array in config/app.php

\Sco\ActionLog\LaravelServiceProvider::class,

If you want to use the facade to logging actions, add this to the aliases array in config/app.php

'ActionLog' => Sco\ActionLog\Facade::class,

Publish config file

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Sco\ActionLog\LaravelServiceProvider"

Default action log table name is action_logs, If you want to customize it, edit the config/actionlog.php

Now run the artisan migrate command:

php artisan migrate

Usage

Method 1

Override the property $events in your Model

    protected $events = [
        'created'  => \Sco\ActionLog\Events\ModelWasCreated::class,
    ];

⚠ Note: Laravel 5.5
Renamed $events to $dispatchesEvents (#17961, b6472bf, 3dbe12f)

All available event

[
    'created'   => \Sco\ActionLog\Events\ModelWasCreated::class,
    'deleted'   => \Sco\ActionLog\Events\ModelWasDeleted::class,
    'restored'  => \Sco\ActionLog\Events\ModelWasRestored::class,
    'saved'     => \Sco\ActionLog\Events\ModelWasSaved::class,
    'updated'   => \Sco\ActionLog\Events\ModelWasUpdated::class,
    'creating'  => \Sco\ActionLog\Events\ModelWillCreating::class,
    'deleting'  => \Sco\ActionLog\Events\ModelWillDeleting::class,
    'restoring' => \Sco\ActionLog\Events\ModelWillRestoring::class,
    'saving'    => \Sco\ActionLog\Events\ModelWillSaving::class,
    'updating'  => \Sco\ActionLog\Events\ModelWillUpdating::class,
]

Method 2

Manual logging actions

// use event
event(new \Sco\ActionLog\Events\ManualEvent($type, $content));

// use factory
\Sco\ActionLog\Factory::info(LogInfo $info);

Change log

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

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email slice1213@gmail.com instead of using the issue tracker.

Credits

License

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