Laravel 审计:更改默认 table 名称 "audits"

Laravel auditing: change the default table name "audits"

由于我们在项目中已经使用了审核 table,有没有办法将 table 名称从“audits”更改为喜欢“audit_trail_histories” “?

http://www.laravel-auditing.com/docs/4.1/general-configuration

The Database driver allows modifying:

  • The database connection.
  • The table where the Audit records are stored.

.

return [
    // ...
    'drivers' => [
        'database' => [
            'table'      => 'audits',
            'connection' => null,
        ],
    ],
    // ...
];

更新迁移文件中的 up()down() 方法,以便将 audit_trail_histories 设置为 table 名称。

// ...

Schema::create('audit_trail_histories', function (Blueprint $table) {
    // ...
});

// ...

Schema::drop('audit_trail_histories');

// ...

执行php artisan migrate创建table。

像这样更新配置:

return [
    // ...

    'drivers' => [
        'database' => [
            'table' => 'audit_trail_histories',
            // ...
        ],
    ],

    // ...
];

就是这样!