This commit is contained in:
Lizandro Guarnizo
2026-01-29 16:15:28 -05:00
parent d0ab74d3fc
commit 00767382b5
3 changed files with 115 additions and 8 deletions
@@ -43,19 +43,27 @@ class ScanResourcesPermissions extends Command
$filename = pathinfo($file->getFilename(), PATHINFO_FILENAME);
$className = 'App\\Filament\\Resources\\' . $filename;
// Intentar obtener un label legible: preferimos el método getNavigationLabel(), luego la propiedad estática
// Intentar obtener un label legible: preferimos el método getPluralModelLabel(), luego getNavigationLabel(), luego la propiedad estática
$label = null;
$pluralLabel = null;
if (class_exists($className)) {
if (method_exists($className, 'getNavigationLabel')) {
$label = $className::getNavigationLabel();
} elseif (isset($className::$navigationLabel)) {
$label = $className::$navigationLabel;
if (method_exists($className, 'getPluralModelLabel')) {
$pluralLabel = $className::getPluralModelLabel();
}
if (! $pluralLabel && method_exists($className, 'getNavigationLabel')) {
$pluralLabel = $className::getNavigationLabel();
}
if (! $pluralLabel && isset($className::$navigationLabel)) {
$pluralLabel = $className::$navigationLabel;
}
}
// Si no hay label, usar el nombre del archivo sin extensión ni sufijo Resource
if ($label) {
$base = Str::lower($label);
// Si no hay label plural, usar el nombre del archivo sin sufijo Resource
if ($pluralLabel) {
$base = Str::lower($pluralLabel);
} else {
$base = Str::lower(Str::replaceLast('Resource', '', $filename));
}