Skip to content

Commit

Permalink
Update FilamentShield.php
Browse files Browse the repository at this point in the history
Adding Extra Heading value check
  • Loading branch information
mahdimirhendi authored Dec 20, 2024
1 parent 8110cf9 commit a6ff23e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/FilamentShield.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,19 @@ public static function getLocalizedWidgetLabel(string $widget): string

return match (true) {
$widgetInstance instanceof TableWidget => (string) invade($widgetInstance)->makeTable()->getHeading(),
! ($widgetInstance instanceof TableWidget) && $widgetInstance instanceof Widget && method_exists($widgetInstance, 'getHeading') => (string) invade($widgetInstance)->getHeading(),
self::hasValidHeading($widgetInstance) => (string) invade($widgetInstance)->getHeading(),
default => str($widget)
->afterLast('\\')
->headline()
->toString(),
};
}

private static function hasValidHeading($widgetInstance): bool
{
return $widgetInstance instanceof Widget
&& method_exists($widgetInstance, 'getHeading')
&& $widgetInstance->getHeading() !== null;
}
protected function getDefaultPermissionIdentifier(string $resource): string
{
return Str::of($resource)
Expand Down

0 comments on commit a6ff23e

Please sign in to comment.