up
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user