@extends('layouts.admin') @section('title', 'Dashboard') @section('heading', 'Dashboard') @section('subheading', 'Welcome back, ' . (auth()->user()?->name ?? '')) @section('header-actions') @endsection @section('content') {{-- ── Stat cards ──────────────────────────────────────────────── --}}
{{-- ── Charts row ──────────────────────────────────────────────── --}}
@if (count($revenue['years']) > 1)
@endif
@if ($revenue['has_data'])

Total Revenue

Rs {{ number_format($revenue['total']) }}

@if ($revenue['growth'] && $revenue['growth']['percent'] !== null) {{ $revenue['growth']['percent'] }}% vs {{ $revenue['year'] - 1 }} @endif
{{-- Height is reserved here rather than left for the chart to establish, so the panel does not jump when the series draws. It also gives the lazy observer in initCharts() a real box to intersect with instead of a zero-height one. --}} @else @endif
@if ($statusMix['has_data']) @else @endif
{{-- ── Activity row ────────────────────────────────────────────── --}}
@if ($activations['has_data']) @else @endif @forelse ($recentlyActivated as $license)
{{ \Illuminate\Support\Str::of($license->customer?->company_name ?? '?')->explode(' ')->take(2)->map(fn ($p) => mb_substr($p, 0, 1))->implode('') }}

{{ $license->customer?->company_name ?? 'Unknown' }}

{{ $license->domain?->domain ?? 'no domain bound' }}

@if ($license->package) {{ $license->package->name }} @endif

{{ $license->activated_at?->diffForHumans(short: true) }}

@empty @endforelse
@forelse ($latestVerifications as $log) @php $failed = $log->event === \App\Models\LicenseLog::FAILED_VERIFICATION; @endphp

{{ $log->domain ?? $log->license?->customer?->company_name ?? 'Unknown' }}

{{ $log->created_at?->diffForHumans() }}

{{ $failed ? 'Invalid' : 'Valid' }}
@empty @endforelse
{{-- ── Updates + expiring row ──────────────────────────────────── --}}
@forelse ($expiringSoon as $license) @php $days = (int) now()->diffInDays($license->expires_at, false); @endphp

{{ $license->customer?->company_name ?? 'Unknown' }}

{{ $license->package?->name }}

{{ $days }} day{{ $days === 1 ? '' : 's' }} left
@empty @endforelse
@if ($updates['has_data'])

v{{ $updates['latest']['version'] }}

{{ ucfirst($updates['latest']['channel']) }}

Released {{ $updates['latest']['published_at'] ?? '—' }}

Installs
{{ number_format($updates['installations']) }}
Pending
{{ number_format($updates['pending']) }}
Failed
{{ number_format($updates['failed']) }}
@else @endif
@if ($updates['has_data'] && $updates['installations'] > 0)

{{ number_format($updates['pending']) }}

installation{{ $updates['pending'] === 1 ? '' : 's' }} pending update

{{ number_format($updates['on_latest']) }} up to date {{ $updates['percent'] }}%
@else @endif
{{-- ── Quick actions ───────────────────────────────────────────── --}}

Quick Actions

@php $isOwner = auth()->user()?->isOwner() ?? false; @endphp {{-- State-changing actions are owner-only (audit M-06), so a viewer sees them disabled rather than getting a 403 after clicking. --}}
@endsection