days, self::PERIODS, true)) { $this->days = 30; } } public function updatedDays(): void { $this->mount(); } public static function canAccess(): bool { return Auth::user()?->can('panel.access') ?? false; } public static function getNavigationGroup(): string|UnitEnum|null { return __('panel.groups.content'); } public static function getNavigationLabel(): string { return __('panel.statistics.title'); } public function getTitle(): string|Htmlable { return __('panel.statistics.title'); } public function stats(): ViewStats { return new ViewStats($this->days); } /** * "+52 %", "−10 %", or "new" when there was nothing to compare with. */ public function change(int $now, int $before): string { if ($before === 0) { return $now > 0 ? __('panel.statistics.new') : '—'; } $percent = (int) round(($now - $before) * 100 / $before); return ($percent > 0 ? '+' : ($percent < 0 ? '−' : '')).abs($percent).' %'; } }