getLabel(); if (filled($label)) { $translatedLabel = translate($label); $this->label(ucfirst($translatedLabel)); } return $this; }); Tab::macro('localizeLabel', function () { $label = $this->getLabel(); if (filled($label)) { $translatedLabel = translate($label); $this->label(ucfirst($translatedLabel)); } return $this; }); } public static function localizeLabelGeneric($object, string | Htmlable | Closure | null $customLabel = null) { $label = filled($customLabel) ? $customLabel : static::processedLabel($object->getLabel()); $object->label(translate($label)); return $object; } public static function processedLabel(Htmlable | null | string $label): string { if (str_ends_with($label, ' id')) { $label = str_replace(' id', '', $label); } return ucfirst($label); } }