{{-- brafa Systems — Dashboard. Mirror of prototype/admin/app.jsx → DashboardView. All figures come from the read-only App\Http\Livewire\Dashboard\Overview component (local DB only). No wire:* state here beyond row navigation links. --}} @php $brafaTilePalette = ['#1A1A1A','#3A3A3A','#5A5A5A','#2D4A33','#3A4D6C','#4D3A6C','#6C3A53','#1E8A3E','#8C5F1B']; @endphp
{{-- Stats strip --}}
Properties {{ $stats['properties'] }}
In-house guests {{ $stats['in_house'] }}
Arrivals today {{ $stats['arrivals'] }}
Assigned locks {{ $stats['assigned_locks'] }}
{{-- Door analytics control — superadmins generate fleet stats on demand --}} @if ($doorOnDemand)

Fleet door analytics

@if ($doorReady && $doorGeneratedAt) Generated {{ \Carbon\Carbon::parse($doorGeneratedAt)->diffForHumans() }} · spans every property's locks @else Computed across the whole fleet's lock history, so it runs on demand rather than on every page load. @endif
@endif @if ($doorReady) {{-- Door activity (everyone) --}}
Door opens today
{{ number_format($door['today']) }}
Avg opens / day
{{ number_format($door['avg_per_day']) }}
Busiest hour
{{ $door['busiest_hour'] ?? '—' }}
Busiest day
{{ $door['busiestDay'] ?? '—' }}
@if ($door['battery'])
Locks low on battery
{{ number_format($door['battery']['low']) }}
@endif
{{-- Opening heatmap (everyone) — day-of-week × hour over the last 4 weeks --}}

Opening heatmap

last 4 weeks · {{ number_format($door['window_total']) }} opens
@if (!empty($door['needs_index'])) Door analytics are paused until the database migration runs (php artisan migrate) — the lock-records index isn't in place yet. @elseif ($door['window_total'] > 0) @php $hm = $door['heatmap']; $hmMax = max(1, $door['heatmap_max']); $days = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']; @endphp
{{-- hour axis --}}
@for ($h = 0; $h < 24; $h++) {{ $h % 6 === 0 ? $h : '' }} @endfor
@foreach ($days as $di => $dl)
{{ $dl }} @for ($h = 0; $h < 24; $h++) @php $c = $hm[$di][$h] ?? 0; $a = $c > 0 ? round(0.12 + 0.88 * ($c / $hmMax), 3) : 0; @endphp @endfor
@endforeach
@else No door openings recorded in the last 4 weeks. @endif
{{-- Latest openings (everyone) --}}

Latest openings

live · last {{ count($openings) }}
@forelse ($openings as $o) @empty @endforelse
Time Lock Room Type Who
{{ $o['time'] }} {{ $o['alias'] }} @if ($o['is_room']) {{ $o['room'] }} @else {{ $o['room'] }} @endif @php $tIcon = $o['type'] === 'Card' ? 'credit-card' : ($o['type'] === 'Passcode' ? 'lock' : 'zap'); @endphp {{ $o['type'] }} {{ $o['who'] }}
No door openings recorded yet.
@endif {{-- $doorReady --}} {{-- Superadmin fleet stats --}} @if ($isAdmin && $superStats)
Active codes
{{ number_format($superStats['active_codes']) }}
Avg occupancy
{{ $superStats['avg_occupancy'] }}%
Departures today
{{ $superStats['departures'] }}
Upcoming · 7 days
{{ $superStats['upcoming'] }}
@endif {{-- Door-code health (everyone) --}} @php $codeBarClass = fn ($status) => in_array(strtolower($status), ['success', 'sent', 'active'], true) ? 'is-high' : (in_array(strtolower($status), ['failed', 'unsent'], true) ? 'is-low' : 'is-mid'); $codeMax = $codeHealth['by_status']->max() ?: 1; @endphp

Door-code health

{{ number_format($codeHealth['total']) }} {{ \Illuminate\Support\Str::plural('code', $codeHealth['total']) }} @if ($codeHealth['pending'] > 0) · {{ number_format($codeHealth['pending']) }} pending @endif
@if ($codeHealth['total'] > 0)
@foreach ($codeHealth['by_status'] as $status => $count)
{{ $status }} {{ number_format($count) }}
@endforeach
@else No door codes issued yet. @endif
{{-- Most active today --}}

Most active today

View all
@forelse ($mostActive as $p) @php $initials = collect(explode(' ', trim((string) $p->name))) ->filter()->take(2)->map(fn ($x) => strtoupper(mb_substr($x, 0, 1)))->implode(''); $tileBg = $brafaTilePalette[crc32((string) $p->id) % count($brafaTilePalette)]; $occClass = $p->occupancy >= 90 ? 'is-high' : ($p->occupancy >= 60 ? 'is-mid' : ($p->occupancy > 0 ? 'is-low' : 'is-empty')); @endphp @empty @endforelse
Property Arrivals Occupancy
{{ $p->name }}
{{ $p->id }} · {{ $p->api }}
{{ $p->arrivals }}
{{ $p->occupancy }}%
No arrivals or in-house guests today.
{{-- Needs attention --}}

Needs attention

@forelse ($alerts as $alert)
{{ $alert['title'] }} {{ $alert['body'] }}
@empty
All clear Nothing needs attention right now.
@endforelse
{{-- Superadmin: fleet composition --}} @if ($isAdmin && $fleet)
{{-- By integration --}}

By integration

{{ $fleet['apis'] }} {{ \Illuminate\Support\Str::plural('source', $fleet['apis']) }}
@php $maxApi = $integrations->max() ?: 1; @endphp
@forelse ($integrations as $api => $count)
{{ $api }} {{ $count }}
@empty No properties yet. @endforelse
{{-- Fleet totals --}}

Fleet

Rooms {{ number_format($fleet['rooms']) }}
Staff {{ number_format($fleet['staff']) }}
dkPlus customers {{ number_format($fleet['customers']) }}
@if ($fleetDoor && $doorReady)
Unlocks · 28 days {{ number_format($fleetDoor['window_total']) }}
@endif
@if ($fleetDoor && $doorReady && $fleetDoor['busiest'])
Busiest today {{ $fleetDoor['busiest']['name'] }} · {{ number_format($fleetDoor['busiest']['unlocks']) }}
@endif @if ($doorReady && $door['battery'])
Battery health {{ $door['battery']['healthy_pct'] }}% ok · {{ $door['battery']['tracked'] }} tracked
@endif
{{-- Invoicing (dkPlus) --}} @if ($invoicing)

Invoicing

dkPlus · {{ $invoicing['current_month'] }}
Total invoices {{ number_format($invoicing['total']) }}
This month {{ number_format($invoicing['this_month']) }}
Properties invoiced {{ number_format($invoicing['properties']) }}
By status @php $invMax = $invoicing['by_status']->max() ?: 1; @endphp
@forelse ($invoicing['by_status'] as $status => $count)
{{ $status }} {{ $count }}
@empty No invoices yet. @endforelse
@endif @endif