Laravel审计:更改默认表名“审计”

Since we are using the audits table already in our project, is there any way to change the table name from "audits" to like "audit_trail_histories"?

Update the up() and down() methods in the migration file, so that audit_trail_histories is set as the table name.

// ...

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

// ...

Schema::drop('audit_trail_histories');

// ...

Execute php artisan migrate to create the table.

Update the configuration like so:

return [
    // ...

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

    // ...
];

That's it!

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,
        ],
    ],
    // ...
];