Skip to content

Commit

Permalink
Update FilamentShield.php
Browse files Browse the repository at this point in the history
  • Loading branch information
wychoong committed Aug 25, 2023
1 parent d43bbc5 commit 6f7681c
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 6f7681c

Please sign in to comment.