定制 odilov-sh/laravel-audit-tm 二次开发

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

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

odilov-sh/laravel-audit-tm

Composer 安装命令:

composer require odilov-sh/laravel-audit-tm

包简介

Laravel Auditor Package

README 文档

README

About

This package provides a simple way to audit your Eloquent models. The package collects the following information:

  • service_id - The ID of the service that is using the package
  • user_id - The user who performed the action
  • event - The event that was performed.
  • auditable_type - The class name of the auditable model. Defaults to model class name. You can override getAuditableClassName() in your model.
  • auditable_id - The ID of the auditable model. You can override getAuditableId() in your model.
  • old_values - The old values of the auditable model
  • new_values - The new values of the auditable model
  • tags - Additional tags. You can override getAuditableTags() in your model.
  • url - The URL of the request
  • ip_address - The IP address of the request
  • user_agent - The user agent of the request

If you use the Astrotomic\Translatable\Translatable trait, the package will also collect the translations of the auditable model, like name_uz, title_uz and so on.

Installation

composer require odilov-sh/laravel-audit-tm

Publishing

php artisan vendor:publish --provider="OdilovSh\LaravelAuditTm\AuditTmServiceProvider"

Envirement variables

Your .env file must have the following variables:

AUTH_SERVICE_ID=1111
AUDIT_TM_SECRET_KEY="your secret key"
AUDIT_TM_ENABLED=true // if false, audit will not be sent
AUDIT_TM_BASE_URL="audit receiver base url"

Usage

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{

    use OdilovSh\LaravelAuditTm\Traits\Auditable;

}

The Auditable trait will automatically send data to audit server on updated, created and deleted events. In other cases, you must send data manually. Manually send data might be like this:

// Manually send data to audit server

use OdilovSh\LaravelAuditTm\AuditSender;

$data = [];
$data['event'] = 'changeStatus'; // Event name
$data['auditable_type'] = 'App\Models\Product'; // The name of the class being audited
$data['auditable_id'] = 123; // The id of the model being audited

// Old values before changing
$data['old_values'] = [
    'status' => 'active'
];

// New values after changing
$data['new_values'] = [
    'status' => 'inactive'
];

(new AuditSender($data))->send();

Queue

You can use queue job to send auditing data to audit server. In this case, you will not wait sending request to audit server and getting response. All of processes will be done in background. To use queue, first you must configure queue settings in Laravel. Then you just need add new configs to env file

AUDIT_TM_QUEUE_IS_ENABLED=true
AUDIT_TM_ON_QUEUE=default

Notes

This package uses OdilovSh\LaravelAuditTm\Resolvers\UserIdResolver to resolve the user id. You can change the resolver by changing the user_id_resolver in the audit-tm config file. As well you can set false this configuration. In this case user_id value will not be sent.

odilov-sh/laravel-audit-tm 适用场景与选型建议

odilov-sh/laravel-audit-tm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.86k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 odilov-sh/laravel-audit-tm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 odilov-sh/laravel-audit-tm 我们能提供哪些服务?
定制开发 / 二次开发

基于 odilov-sh/laravel-audit-tm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-07