lakasir/user-logging-activity

user-logging-activity package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events. All activity will be stored in the activity_log table.

v1.0-beta.2 2020-09-03 02:34 UTC

This package is auto-updated.

Last update: 2022-08-15 16:28:56 UTC


README

Latest Version on Packagist Quality Score Total Downloads

The lakasir/user-logging-activity package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events. All activity will be stored in the activity_log table.

Installation

You can install the package via composer:

composer require lakasir/user-logging-activity

Publish migration and config file with:

php artisan log-activity:install
php artisan migrate

Usage

First define which model you want to record:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Lakasir\UserLoggingActivity\Traits\HasLog;

class Purchasing extends Model
{
    use HasLog;
    
}

Use Lakasir\UserLoggingActivity\Facades\Activity; facade:

Create simple log:

Activity::info('Logged In at '. now()->format('Y-m-d'));

Create more advaced log

$data = Purchasing::create($request->all());

Activity::modelable($data)->auth()->creating();

You can get all activity just use the Lakasir\UserLoggingActivity\Models\Activity; model:

Activity::all();

Available chaining action method

  • creating() for creating info
  • updating() for updating info
  • sync() for dispatch now action
    • You can set default queue action in acitivity_log.queable, if the value is false you didn't need this chaining, if true checkout the job laravel documentation
  • auth() for authenticable user
    • Set default user model in activity_log.user_model
  • modelable($model) pass the related activity

Testing

under development

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

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

Credits