earmsby's avatar

change title of audits relation manager tab

I'm using owen-it / laravel-auditing along with TappNetwork / filament-auditing to show an audit trail on one or more resources in my Filament app. All is working well with basics of it, but I'd like to simply change the name of the tab from "audits" to "Audit Trail." It seems I should be able to simply add

protected function getTableHeading(): ?string
    {
        return 'Audit Trail';
    }

to the relation manager. But the relation manager is only in the node_modules directory. Is it possible to publish this? I didn't see a command for this in the install instructions for the package.

Maybe there's another way to do it - perhaps in config/filament-auditing.php?

1 like
1 reply
LaryAI's avatar
Level 58

To customize the tab title for the audits relation manager when using TappNetwork/filament-auditing, you’ll need to override the default relation manager class, since, by default, the package registers its own and it is not published to your app/Filament directory.

Here’s how you can achieve this:

1. Create Your Own Relation Manager

First, generate a new Relation Manager for the audits relationship in your resource. For example, if you have a PostResource:

php artisan make:FilamentRelationManager PostResource audits

This will create a file at:
app/Filament/Resources/PostResource/RelationManagers/AuditsRelationManager.php

2. Customize the Table Heading

Inside this file, override the getTableHeading method:

<?php

namespace App\Filament\Resources\PostResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;

class AuditsRelationManager extends RelationManager
{
    protected static string $relationship = 'audits';

    // ...existing code...

    protected function getTableHeading(): ?string
    {
        return 'Audit Trail';
    }
}

3. Register Your Relation Manager in the Resource

In your PostResource.php (in the getRelations method), make sure to use your own relation manager:

use App\Filament\Resources\PostResource\RelationManagers\AuditsRelationManager;

// ...

public static function getRelations(): array
{
    return [
        AuditsRelationManager::class,
    ];
}

4. Remove the Package's Default Relation Manager

If you previously referenced the package's built-in audits relation manager in your resource, remove it. Only keep your custom one.


Note

There is currently no way to customize this from a config file or by publishing package stubs; you must create your own relation manager as shown above.


In summary:
Override the audits relation manager in your resource, and you can change the table/tab title to "Audit Trail" or any title you wish.

Let me know if you need more help!

Please or to participate in this conversation.