Skip to content

Latest commit

 

History

History
134 lines (95 loc) · 4.29 KB

README.md

File metadata and controls

134 lines (95 loc) · 4.29 KB

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 [email protected] instead of using the issue tracker.

Credits

License

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