lisi4ok/yii2-auditlog

Yii2 审计日志。此扩展记录所有模型操作 -> find/insert/update/delete。

安装数: 4,549

依赖项: 0

建议者: 0

安全性: 0

星标: 4

关注者: 2

分支: 4

开放问题: 1

类型:yii2-extension

dev-master 2022-10-04 12:15 UTC

This package is auto-updated.

Last update: 2024-09-04 16:41:46 UTC


README

Yii2 审计日志。此扩展记录所有模型操作 -> find/insert/update/delete。

安装

安装此扩展的首选方式是通过 Composer

运行以下命令之一

php composer.phar require --prefer-dist lisi4ok/yii2-auditlog "*"

或者在您的 composer.json 文件的 require 部分添加

"lisi4ok/yii2-auditlog": "*"

前往 yii 应用程序文件夹。然后输入

./yii migrate --migrationPath=@vendor/lisi4ok/yii2-auditlog/migrations

用法

<?php
namespace app\models;
use Yii;
use lisi4ok\auditlog\behaviors\LoggableBehavior;

class MyModel extends \yii\db\ActiveRecord
{
	public function behaviors() {
		return [
			[
				'class' => LoggableBehavior::className(),
				'ignoredAttributes' => ['created_at', 'updated_at', 'created_by', 'updated_by'], // default []
				'ignorePrimaryKey' => true, // default false
				'ignorePrimaryKeyForActions' => ['insert', 'update'], //default [] Note: (if ignorePrimaryKey set to true, ignorePrimaryKeyForActions is empty will apply for all)
				'dateTimeFormat' => 'Y-m-d H:i:s', // default 'Y-m-d H:i:s'
			],
		];
	}
}