Render relation manager under condition

Is in filament possible to show relations only under some condition ? I need to show ProductsRelationManager only, if the edited Category isnt parent. Image is just example, what I would like to create.
No description
2 Replies
Jonas
Jonas5d ago
Yes, use the canViewForRecord() method in the relationshipmanager.
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
return $ownerRecord->can_view;
}
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
return $ownerRecord->can_view;
}
Godíkos
GodíkosOP5d ago
Thast pretty cool ! I finally found it in the documentation https://filamentphp.com/docs/3.x/panels/resources/relation-managers#conditionally-showing-relation-managers Thank you for your advice !

Did you find this page helpful?