From 6f7681c13e718216a104c4877564d310aa2ca2f3 Mon Sep 17 00:00:00 2001 From: wychoong <67364036+wychoong@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:02:20 +0800 Subject: [PATCH] Update FilamentShield.php --- src/FilamentShield.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/FilamentShield.php b/src/FilamentShield.php index d4f2c391..65117c5f 100755 --- a/src/FilamentShield.php +++ b/src/FilamentShield.php @@ -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