-
app/helpers.php
Open in GitHub// ... if (!function_exists('convert_bytes_to_readable')) { function convert_bytes_to_readable(int $bytes, int $decimals = 2, ?int $base = null): string { $conversionUnit = config('panel.use_binary_prefix') ? 1024 : 1000; $suffix = config('panel.use_binary_prefix') ? ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB'] : ['Bytes', 'KB', 'MB', 'GB', 'TB']; if ($bytes <= 0) { return '0 ' . $suffix[0]; } $fromBase = log($bytes) / log($conversionUnit); $base ??= floor($fromBase); return Number::format(pow($conversionUnit, $fromBase - $base), $decimals, locale: auth()->user()->language) . ' ' . $suffix[$base]; } } // ...
-
composer.json
Open in GitHub{ // ... "autoload": { "files": [ "app/helpers.php" ], "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/Factories/", "Database\\Seeders\\": "database/Seeders/" } }, // ... }
-
app/Filament/Admin/Resources/NodeResource/Widgets/NodeStorageChart.php
Open in GitHubclass NodeStorageChart extends ChartWidget { // ... public function getHeading(): string { $used = convert_bytes_to_readable($this->node->statistics()['disk_used']); $total = convert_bytes_to_readable($this->node->statistics()['disk_total']); return trans('admin/node.disk_chart', ['used' => $used, 'total' => $total]); } }