count()) ->icon('heroicon-o-document-text') ->color('primary'), Stat::make(__('panel.widgets.stats.published'), Page::query()->published()->count()) ->icon('heroicon-o-check-circle') ->color('success'), // The metric an editorial team actually acts on: content that is // live in one language but still missing in another. Stat::make(__('panel.widgets.stats.missing_translations'), $this->untranslatedCount()) ->description(__('panel.widgets.stats.missing_translations_hint')) ->icon('heroicon-o-language') ->color($this->untranslatedCount() > 0 ? 'warning' : 'gray'), Stat::make(__('panel.widgets.stats.users'), User::query()->active()->count()) ->icon('heroicon-o-users') ->color('gray'), ]; } /** * Pages lacking a title in at least one supported locale. */ protected function untranslatedCount(): int { return Page::query() ->where('status', '!=', PageStatus::Archived) ->where(function (Builder $query): void { foreach (array_keys(config('locales.supported')) as $locale) { $query->orWhereNull("title->{$locale}") ->orWhere("title->{$locale}", ''); } }) ->count(); } public static function canView(): bool { return auth()->user()?->can('pages.view_any') ?? false; } }