Laravel auditing: change the default table name "audits"

1.1k Views Asked by At

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"?

2

There are 2 best solutions below

2
Quetzy Garcia On BEST ANSWER

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!

2
ceejayoz On

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