© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
Eric

Conditionally show relation manager

My items model, if a condition is met, will be able to have users or not.

This condition can be calculated by retrieving the model and doing some simple checks on it.

As i know which models can have users or not, i want to hide the users table in the edit page when they aren't able to have that relationship. any ideas how to achieve it?

public static function getRelations(): array
{
    return [
        RelationManagers\UsersRelationManager::class, // how to conditionally add this relation manager or not? i'd grab here the record and would do the checks
    ];
}
public static function getRelations(): array
{
    return [
        RelationManagers\UsersRelationManager::class, // how to conditionally add this relation manager or not? i'd grab here the record and would do the checks
    ];
}
Solution
you can find your answer here:

https://filamentphp.com/docs/3.x/panels/resources/relation-managers#conditionally-showing-relation-managers

You have to edit your RelationManager file and add the canViewForRecord function, and add your conditions inside.
Managing relationships - Panel Builder - Filament
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Conditionally hide relation manager
FilamentFFilament / ❓┊help
2y ago
Conditionally show Relationship (manager)
FilamentFFilament / ❓┊help
2y ago
Show records with Relation Manager
FilamentFFilament / ❓┊help
2y ago
Show relation manager of a relation manager in same view
FilamentFFilament / ❓┊help
2y ago