medicivn/eloquent-logger

v1.0.0 2022-10-17 04:55 UTC

This package is auto-updated.

Last update: 2024-09-17 11:12:47 UTC


README

在更新模型时自动更新日志记录器。

使用方法

  • 首先,在模型表的根节点中初始化
  • use ActivityLogTrait; 添加到您的eloquent模型中,例如
use Medicivn\EloquentLogger\ActivityLogTrait;

class UserTest extends Model
{
    use HasFactory, ActivityLogTrait;
    
    /**
    * The column need note write the change
    *
    * Default: []
    */
    const LOGGABLE = [
        'name',
    ];
    
    /**
    * The model name to record changes
    *
    * Default: null
    */
    const MODEL_NAME_LOG = ActivityUserTestLog::class;
    

函数

  • writeLog:更改数据时写入日志

注意

  • 如果您正在使用ActivityLogTrait for MySQL,请创建具有以下列的表
    • model_id
    • url
    • time
    • creator
    • creator_id
    • action
    • key
    • old_value
    • new_value