Skip to content

Commit

Permalink
Merge pull request #221 from wychoong/2.x-1
Browse files Browse the repository at this point in the history
fix getting label name from wrong class
  • Loading branch information
bezhanSalleh authored Sep 12, 2023
2 parents d43bbc5 + 6f7681c commit 0ca248d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/FilamentShield.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,10 @@ public static function getLocalizedWidgetLabel(string $widget): string

protected static function transformClassString(string $string, bool $isPageClass = true): string
{
$prefix = Str::of($isPageClass ? Utils::getPagePermissionPrefix() : Utils::getWidgetPermissionPrefix())->append('_');

return (string) collect($isPageClass ? Filament::getPages() : Filament::getWidgets())
->first(fn ($item) => Str::endsWith(
$item,
Str::of($string)
->after('_')
->studly()
));
->first(fn ($item) => class_basename($item) == Str::of($string)->after($prefix)->studly());
}

protected static function hasHeadingForShield(object|string $class): bool
Expand Down

0 comments on commit 0ca248d

Please sign in to comment.