F
Filament12mo ago
MeniV

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?
1 Reply
Solution
DrByte
DrByte12mo ago
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);
}
}
class ActivitiesRelationManager extends RelationManager
{
//...
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
if ($pageClass === ViewStaffMember::class) {
return false;
}
return parent::canViewForRecord($ownerRecord, $pageClass);
}
}
Want results from more Discord servers?
Add your server