TenantAtlas/app/Filament/Pages/InventoryCoverage.php
2026-01-10 21:32:34 +01:00

56 lines
1.6 KiB
PHP

<?php
namespace App\Filament\Pages;
use App\Services\Inventory\CoverageCapabilitiesResolver;
use BackedEnum;
use Filament\Pages\Page;
use UnitEnum;
class InventoryCoverage extends Page
{
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-table-cells';
protected static string|UnitEnum|null $navigationGroup = 'Inventory';
protected static ?string $navigationLabel = 'Coverage';
protected string $view = 'filament.pages.inventory-coverage';
/**
* @var array<int, array<string, mixed>>
*/
public array $supportedPolicyTypes = [];
/**
* @var array<int, array<string, mixed>>
*/
public array $foundationTypes = [];
public function mount(): void
{
$policyTypes = config('tenantpilot.supported_policy_types', []);
$foundationTypes = config('tenantpilot.foundation_types', []);
$resolver = app(CoverageCapabilitiesResolver::class);
$this->supportedPolicyTypes = collect(is_array($policyTypes) ? $policyTypes : [])
->map(function (array $row) use ($resolver): array {
$type = (string) ($row['type'] ?? '');
return array_merge($row, [
'dependencies' => $type !== '' && $resolver->supportsDependencies($type),
]);
})
->all();
$this->foundationTypes = collect(is_array($foundationTypes) ? $foundationTypes : [])
->map(function (array $row): array {
return array_merge($row, [
'dependencies' => false,
]);
})
->all();
}
}