ScoLib / laravel-action-log by klgd

A laravel package for logging user actions into the database
929
2
2
Package Data
Maintainer Username: klgd
Maintainer Contact: slice1213@gmail.com (klgd)
Package Create Date: 2017-04-25
Package Last Update: 2018-04-19
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:21:14
Package Statistics
Total Downloads: 929
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

Laravel Action Log

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.