定制 eddytim/auditlog 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eddytim/auditlog

Composer 安装命令:

composer require eddytim/auditlog

包简介

Library for inserting and fetching audit logs easily and sending alert to user

README 文档

README

Latest Version Issues License

Library for inserting and fetching audit logs easily and sending alert to user

Installation

The Audit Log Service Provider can be installed via Composer by requiring the eddytim/auditlog package and setting the minimum-stability to dev (required for Laravel 5) in your project's composer.json.

{
    "require": {
        "laravel/framework": "5.0.*",
        "eddytim/auditlog": "^1.0.0"
    },
    "minimum-stability": "dev"
}

or

Require this package with composer:

composer require eddytim/auditlog

Update your packages with composer update or install with composer install.

Migration

You need to run migration in order to prepare the table(s) needed for the logs. Run a migration:

$ php artisan migrate

Configuration

To insert an email address to send alert, publish config. You will also be able to configure the user model of which audit log belongs to, setting foreign and owner key. You will also be able to set audit log fetch limit of which by default is 50

$ php artisan vendor:publish --provider="Eddytim\Auditlog\AuditLogServiceProvider"

config/audit.php

return [
    'send_email_to'   => '',
    'user_model' => App\Models\User::class,
    'foreign_key' => 'user_id',
    'owner_key' => 'id',
    'audit_logs_limit' => 50,
];

AuditLog Service Provider is automatically added in config/app.php, in case it does not, you must register the provider when bootstrapping your Laravel application.

Find the providers key in config/app.php and register the AuditLog Service Provider.

    'providers' => [
        // ...
        'Eddytim\Auditlog\AuditLogServiceProvider',
    ]

for Laravel 5.1+

    'providers' => [
        // ...
        \Eddytim\Auditlog\AuditLogServiceProvider::class,
    ]

Example Usage

Default without alert on the log

    $log = AuditLog::store([
            'event_status' => 'SUCCESS',
            'event_type' => 'Update',
            'user_id' => Auth::id(),
            'description' => 'Changing user name from (old value) to (new value)',
            'table_name' => null, // insert a table name if you will want to track affected table
            'row_id' => null // insert table row id if you will want to track specific affected record
        ]);

With alert on the log

// Make sure you have your mail configured and published the vendor so as to specify an email address
    $log = AuditLog::store([
            'event_status' => 'SUCCESS',
            'event_type' => 'Update',
            'user_id' => Auth::id(),
            'description' => 'Changing user name from (old value) to (new value)',
            'table_name' => null, // insert a table name if you will want to track affected table
            'row_id' => null // insert table row id if you will want to track specific affected record
        ], 'This is a message to alert you on the changes');

###Fetching the Logs

//    Parameter required is an integer which indicates the offset when fetching the logs
    /**
     * @param $offset
     */
    $logs = AuditLog::getAuditLogs(0);

统计信息

  • 总下载量: 248
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固