{{-- resources/views/admin/analytics.blade.php --}} @extends('admin.layouts.app') @section('title', 'Analytics') @section('page_title', 'Platform Analytics') @section('breadcrumb', 'Platform-wide metrics and trends') @section('content') @php $snapshot = $latest?->snapshot_date?->format('d M Y') ?? 'No snapshot yet'; @endphp {{-- Snapshot notice --}}
Last snapshot: {{ $snapshot }} · Live property counts shown in overview
{{-- Overview Stat Cards --}}
{{ number_format($overview['total_properties']) }}
Total Properties
{{ number_format($overview['active']) }}
Approved & Active
{{ number_format($overview['trialing']) }}
On Trial
{{ number_format($overview['suspended']) }}
Suspended
{{-- Latest snapshot revenue cards --}} @if($latest)
{{ number_format($latest->new_registrations) }}
New Registrations
{{ number_format($latest->total_reservations) }}
Total Reservations
${{ number_format($latest->total_revenue_usd, 0) }}
Total Revenue (USD)
${{ number_format($latest->total_commission_usd, 0) }}
Commission Earned (USD)
@endif
{{-- 30-day history chart --}}
Properties & Registrations — Last 30 Days
@if($history->isEmpty())
No snapshot data yet
@else @endif
{{-- Revenue trend --}} @if($history->isNotEmpty())
Revenue & Commission — Last 30 Days
@endif
{{-- Right column breakdowns --}}
{{-- By Country (live) --}}
By Country Live
@if($overview['by_country']->isEmpty())
No data
@else @php $maxCountry = $overview['by_country']->max(); @endphp @foreach($overview['by_country']->sortDesc()->take(10) as $country => $count)
{{ $country ?: 'Unknown' }} {{ $count }}
@endforeach @endif
{{-- By Property Type (live) --}}
By Property Type Live
@if($overview['by_type']->isEmpty())
No data
@else @php $maxType = $overview['by_type']->max(); @endphp @foreach($overview['by_type']->sortDesc() as $type => $count)
{{ ucfirst(str_replace('_', ' ', $type)) }} {{ $count }}
@endforeach @endif
{{-- Latest snapshot breakdown by plan --}} @if($latest && !empty($latest->breakdown_by_plan))
By Plan {{ $snapshot }}
@php $maxPlan = max($latest->breakdown_by_plan); @endphp @foreach($latest->breakdown_by_plan as $plan => $count)
{{ strtoupper($plan) }} {{ $count }}
@endforeach
@endif
{{-- Snapshot history table --}} @if($history->count() > 1)
Snapshot History Last {{ $history->count() }} days
@foreach($history as $snap) first ? 'style=font-weight:500' : '' }}> @endforeach
Date Total Props Active Trial New Regs Reservations Revenue (USD) Commission (USD)
{{ $snap->snapshot_date->format('d M Y') }} @if($loop->first) latest @endif {{ number_format($snap->total_properties) }} {{ number_format($snap->active_properties) }} {{ number_format($snap->trial_properties) }} @if($snap->new_registrations > 0) +{{ number_format($snap->new_registrations) }} @else 0 @endif {{ number_format($snap->total_reservations) }} ${{ number_format($snap->total_revenue_usd, 2) }} ${{ number_format($snap->total_commission_usd, 2) }}
@endif
@endsection @push('scripts') @if($history->isNotEmpty()) @endif @endpush