{{-- Hausmeister-Dashboard --}} @php $hmUnits = \App\Models\Unit::where('hausmeister_id', auth()->id())->with('property')->get(); $hmPropertyIds = $hmUnits->pluck('property_id')->unique(); $hmTickets = \App\Models\Ticket::whereIn('unit_id', $hmUnits->pluck('id'))->latest()->take(10)->get(); $hmMaintenances = \App\Models\Maintenance::whereIn('property_id', $hmPropertyIds)->orWhereIn('unit_id', $hmUnits->pluck('id'))->orderBy('next_maintenance')->take(5)->get(); $hmKeys = \App\Models\Key::whereIn('unit_id', $hmUnits->pluck('id'))->get(); $hmMeters = \App\Models\Meter::whereIn('unit_id', $hmUnits->pluck('id'))->with('latestReading')->get(); @endphp
{{-- Willkommen --}}

Willkommen, {{ auth()->user()->name }}!

Du bist für {{ $hmUnits->count() }} Einheiten zuständig.

{{-- Stat-Boxen --}}

Einheiten

{{ $hmUnits->count() }}

Offene Tickets

{{ $hmTickets->whereIn('status', ['offen','in_bearbeitung'])->count() }}

Wartungen fällig

{{ $hmMaintenances->where('next_maintenance', '<=', now()->addMonth())->count() }}

Schlüssel

{{ $hmKeys->count() }}

{{-- Offene Tickets --}}

Offene Tickets

@if($hmTickets->isEmpty())

Keine Tickets.

@else @foreach($hmTickets as $t) @endforeach
TitelPrioritätStatusEinheit
{{ $t->title }} {{ $t->priority }} {{ $t->status_label }} {{ $t->unit?->name ?? '-' }}
@endif
{{-- Wartungen + Schlüssel --}}

Anstehende Wartungen

@if($hmMaintenances->isEmpty())

Keine Wartungen.

@else @foreach($hmMaintenances as $m)

{{ $m->title }}

📅 {{ $m->next_maintenance->format('d.m.Y') }} | {{ $m->property->name ?? '' }}

@endforeach @endif

Schlüssel in meinem Besitz

@if($hmKeys->isEmpty())

Keine Schlüssel.

@else @foreach($hmKeys as $k)
{{ $k->name }} - {{ $k->type_label }} @if($k->currentAssignment) ✓ Bei mir @endif
@endforeach @endif
{{-- Zähler meiner Einheiten --}} @if($hmMeters->isNotEmpty())

Zähler meiner Einheiten

@foreach($hmMeters as $m) @endforeach
ZählerEinheitLetzter StandDatum
{{ $m->name ?? $m->type_label }} {{ $m->unit->property->name }} - {{ $m->unit->name }} {{ $m->latestReading ? number_format($m->latestReading->value, 2).' '.$m->unit_label : '-' }} {{ $m->latestReading?->reading_date?->format('d.m.Y') ?? '-' }}
@endif