Gemil Aguinaldo
Gemil Aguinaldo

Reputation: 13

Laravel auditing: change the default table name "audits"

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

Upvotes: 0

Views: 1239

Answers (2)

Quetzy Garcia
Quetzy Garcia

Reputation: 1840

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!

Upvotes: 0

ceejayoz
ceejayoz

Reputation: 180065

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

Upvotes: 0

Related Questions