Hide relationmanager while viewing infolist

Is it possible to hide a relationmanager (for everyone) when an infolist is viewed?
I think some code has to be added to the 'Resource view page' or must it be done by using policies?
Solution
https://filamentphp.com/docs/3.x/panels/resources/relation-managers#conditionally-showing-relation-managers

eg:
class ActivitiesRelationManager extends RelationManager
{
    //...
    public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
    {
        if ($pageClass === ViewStaffMember::class) {
            return false;
        }
        return parent::canViewForRecord($ownerRecord, $pageClass);
    }
}
Was this page helpful?