@props(['expiringDays' => null]) @use('App\Models\Domain') @use('App\Models\License') @use('App\Services\LicenseStatsService') @php /* | The licences controller passes only the paginated list, and this redesign | is not allowed to change it - so the header figures are resolved here, | through the same LicenseStatsService the dashboard already uses. Reusing | that service is the point: "active" folds in real-time expiry in SQL, so | these cards can never disagree with the dashboard's. | | Two counts the service does not expose are added alongside it; both are | single aggregate queries, no per-row work. */ $overview = app(LicenseStatsService::class)->overview(); $total = License::count(); $domains = Domain::whereNotNull('license_id')->count(); $days = $expiringDays ?? (int) config('licensing.expiring_soon_days', 30); $share = fn (int $n) => $total > 0 ? round($n / $total * 100).'% of all licenses' : 'Nothing issued yet'; @endphp