TenantAtlas/app/Support/Inventory/InventoryKpiBadges.php
2026-04-05 14:18:37 +02:00

83 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Inventory;
use Illuminate\Support\Facades\Blade;
class InventoryKpiBadges
{
public static function coverageBreakdown(int $failedCount, int $skippedCount, int $unknownCount): string
{
if ($failedCount === 0 && $skippedCount === 0 && $unknownCount === 0) {
return Blade::render(<<<'BLADE'
<div class="flex items-center gap-2">
<x-filament::badge color="success" size="sm">
No follow-up
</x-filament::badge>
</div>
BLADE);
}
return Blade::render(<<<'BLADE'
<div class="flex flex-wrap items-center gap-2">
@if ($failedCount > 0)
<x-filament::badge color="danger" size="sm">
Failed {{ $failedCount }}
</x-filament::badge>
@endif
@if ($skippedCount > 0)
<x-filament::badge color="warning" size="sm">
Skipped {{ $skippedCount }}
</x-filament::badge>
@endif
@if ($unknownCount > 0)
<x-filament::badge color="gray" size="sm">
Unknown {{ $unknownCount }}
</x-filament::badge>
@endif
</div>
BLADE, [
'failedCount' => $failedCount,
'skippedCount' => $skippedCount,
'unknownCount' => $unknownCount,
]);
}
public static function followUpSummary(?TenantCoverageTypeTruth $topPriorityRow, int $observedItemTotal, int $observedTypeCount): string
{
if (! $topPriorityRow instanceof TenantCoverageTypeTruth) {
return Blade::render(<<<'BLADE'
<div class="flex items-center gap-2">
<x-filament::badge color="success" size="sm">
All covered
</x-filament::badge>
</div>
BLADE);
}
return Blade::render(<<<'BLADE'
<div class="flex flex-wrap items-center gap-2">
<x-filament::badge color="gray" size="sm">
{{ $topPriorityLabel }}
</x-filament::badge>
<x-filament::badge color="info" size="sm">
Observed {{ $observedItemTotal }}
</x-filament::badge>
<span class="text-xs text-gray-600 dark:text-gray-300">
{{ $observedTypeCount }} supported types currently observed
</span>
</div>
BLADE, [
'topPriorityLabel' => $topPriorityRow->label,
'observedItemTotal' => $observedItemTotal,
'observedTypeCount' => $observedTypeCount,
]);
}
}