You've already forked Epicnabbo-Catalogus-Updated-Daily
48 lines
1.8 KiB
PHP
48 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Traits;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
trait TranslatableResource
|
|
{
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
$group = property_exists(static::class, 'navigationGroup') ? static::$navigationGroup : null;
|
|
$groupStr = is_string($group) ? $group : ($group instanceof \UnitEnum ? $group->name : '');
|
|
return __(
|
|
sprintf('filament::resources.navigations.%s', $groupStr),
|
|
);
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
$identifier = property_exists(static::class, 'translateIdentifier') ? static::$translateIdentifier : '';
|
|
$identifierStr = is_string($identifier) ? $identifier : ($identifier instanceof \UnitEnum ? $identifier->name : '');
|
|
return __(sprintf(
|
|
Str::endsWith(static::class, 'RelationManager')
|
|
? 'filament::resources.resources.%s.navigation_label'
|
|
: 'filament::resources.resources.%s.plural',
|
|
$identifierStr,
|
|
));
|
|
}
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
$identifier = property_exists(static::class, 'translateIdentifier') ? static::$translateIdentifier : '';
|
|
$identifierStr = is_string($identifier) ? $identifier : ($identifier instanceof \UnitEnum ? $identifier->name : '');
|
|
return __(
|
|
sprintf('filament::resources.resources.%s.navigation_label', $identifierStr),
|
|
);
|
|
}
|
|
|
|
public static function getModelLabel(): string
|
|
{
|
|
$identifier = property_exists(static::class, 'translateIdentifier') ? static::$translateIdentifier : '';
|
|
$identifierStr = is_string($identifier) ? $identifier : ($identifier instanceof \UnitEnum ? $identifier->name : '');
|
|
return __(
|
|
sprintf('filament::resources.resources.%s.label', $identifierStr),
|
|
);
|
|
}
|
|
}
|