🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 23:22:33 +01:00
parent 7f253b5261
commit 35202aa825
10 changed files with 49 additions and 26 deletions
@@ -2,38 +2,46 @@
namespace App\Filament\Traits;
use Str;
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', static::$navigationGroup),
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',
static::$translateIdentifier,
$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', static::$translateIdentifier),
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', static::$translateIdentifier),
sprintf('filament::resources.resources.%s.label', $identifierStr),
);
}
}
@@ -45,10 +45,10 @@ class ArticlesAggregateChart extends ChartWidget
'datasets' => [
[
'label' => $label,
'data' => $data->map(fn (TrendValue $value) => $value->aggregate),
'data' => $data->map(fn ($value) => data_get($value, 'aggregate')),
],
],
'labels' => $data->map(fn (TrendValue $value) => $value->date),
'labels' => $data->map(fn ($value) => data_get($value, 'date')),
];
}
@@ -20,31 +20,31 @@ class TopDashboardOverview extends BaseWidget
protected function getStats(): array
{
return [
Stat::make(__('filament::resources.stats.users_count.title'), Number::format(User::count(), '0', '1', app()->getLocale()))
Stat::make(__('filament::resources.stats.users_count.title'), Number::format(User::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.users_count.description'))
->chart([20, 20])
->descriptionIcon('heroicon-m-user-group', IconPosition::Before)
->color('success'),
Stat::make(__('filament::resources.stats.furniture_count.title'), Number::format(ItemDefinition::count(), '0', '1', app()->getLocale()))
Stat::make(__('filament::resources.stats.furniture_count.title'), Number::format(ItemDefinition::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.furniture_count.description'))
->descriptionIcon('heroicon-m-cube', IconPosition::Before)
->chart([20, 20])
->color('success'),
Stat::make(__('filament::resources.stats.rooms_count.title'), Number::format(Room::count(), '0', '1', app()->getLocale()))
Stat::make(__('filament::resources.stats.rooms_count.title'), Number::format(Room::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.rooms_count.description'))
->descriptionIcon('heroicon-m-building-storefront', IconPosition::Before)
->chart([20, 20])
->color('success'),
Stat::make(__('filament::resources.stats.photos_count.title'), Number::format(CameraWeb::count(), '0', '1', app()->getLocale()))
Stat::make(__('filament::resources.stats.photos_count.title'), Number::format(CameraWeb::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.photos_count.description'))
->descriptionIcon('heroicon-m-camera', IconPosition::Before)
->chart([20, 20])
->color('success'),
Stat::make(__('filament::resources.stats.badge_count.title'), Number::format(WebsiteBadge::count(), '0', '1', app()->getLocale()))
Stat::make(__('filament::resources.stats.badge_count.title'), Number::format(WebsiteBadge::count(), 0, 1, app()->getLocale()))
->description(__('filament::resources.stats.badge_count.description'))
->descriptionIcon('heroicon-m-gif', IconPosition::Before)
->chart([20, 20])