diff --git a/src/Concerns/HandlesOverlookWidgetCustomization.php b/src/Concerns/HandlesOverlookWidgetCustomization.php index 20ce769..ba3fa37 100644 --- a/src/Concerns/HandlesOverlookWidgetCustomization.php +++ b/src/Concerns/HandlesOverlookWidgetCustomization.php @@ -1,5 +1,7 @@ getId()); } - public function boot(Panel $panel): void + public function getId(): string { + return 'awcodes/overlook'; } - public static function make(): static - { - return app(static::class); - } + public function register(Panel $panel): void {} - public static function get(): static - { - return filament(app(static::class)->getId()); - } + public function boot(Panel $panel): void {} - public function alphabetical(bool | Closure | null $condition = true): static + public function alphabetical(bool|Closure|null $condition = true): static { $this->shouldSortAlphabetical = $condition; return $this; } - public function abbreviateCount(bool | Closure | null $condition = true): static + public function abbreviateCount(bool|Closure|null $condition = true): static { $this->shouldAbbreviateCount = $condition; return $this; } - public function excludes(array | Closure $resources): static + public function excludes(array|Closure $resources): static { $this->excludes = $resources; @@ -103,7 +101,7 @@ public function getSort(): int return $this->evaluate($this->sort) ?? -1; } - public function includes(array | Closure $resources): static + public function includes(array|Closure $resources): static { $this->includes = $resources; @@ -125,21 +123,21 @@ public function shouldSortAlphabetical(): bool return $this->evaluate($this->shouldSortAlphabetical) ?? false; } - public function sort(int | Closure $sort): static + public function sort(int|Closure $sort): static { $this->sort = $sort; return $this; } - public function tooltips(bool | Closure | null $condition = true): static + public function tooltips(bool|Closure|null $condition = true): static { $this->shouldShowTooltips = $condition; return $this; } - public function icons(array | Closure | null $icons): static + public function icons(array|Closure|null $icons): static { $this->icons = $icons; diff --git a/src/OverlookServiceProvider.php b/src/OverlookServiceProvider.php index 8f3a11f..62d4043 100644 --- a/src/OverlookServiceProvider.php +++ b/src/OverlookServiceProvider.php @@ -1,12 +1,14 @@ getSort(); + } + /** * @throws Exception */ @@ -36,7 +43,7 @@ public function mount(): void } } - public function convertCount(string $number): string + public function convertCount(string | int | float $number): string { if (OverlookPlugin::get()->shouldAbbreviateCount()) { $formatter = new NumberFormatter( @@ -44,15 +51,15 @@ public function convertCount(string $number): string NumberFormatter::PATTERN_DECIMAL, ); - return $formatter->format($number); + return $formatter->format((int) $number); } return $number; } - public function formatRawCount(string $number): string + public function formatRawCount(string | int | float $number): string { - return number_format($number); + return number_format((int) $number); } /** @@ -105,15 +112,10 @@ public function getData(): array ->toArray(); } - public static function getSort(): int - { - return OverlookPlugin::get()->getSort(); - } - public function shouldShowTooltips(string $number): bool { $plugin = OverlookPlugin::get(); - return strlen($number) >= 4 && $plugin->shouldAbbreviateCount() && $plugin->shouldShowTooltips(); + return mb_strlen($number) >= 4 && $plugin->shouldAbbreviateCount() && $plugin->shouldShowTooltips(); } }