@extends('layouts.admin') @section('title', setting('school_name', 'ShulePoint') . ' | Inbox') @section('page-title', 'Messages') @section('content')

Inbox

{{-- Left: senders (one row per user) --}}
@php try { $inboxSchoolMap = \Illuminate\Support\Facades\Cache::remember('shulepoint.school-map', 600, fn () => \App\Models\School::pluck('name', 'id')->all()); } catch (\Throwable $e) { $inboxSchoolMap = []; } $showInboxSchool = \App\Support\CurrentSchool::id() === 'all'; @endphp @forelse ($threads as $t) @php $isOpen = isset($openSenderId) && $openSenderId == $t['sender_id']; @endphp {{ strtoupper(substr($t['sender']->name ?? 'U', 0, 1)) }} {{ $t['sender']->name ?? 'User' }} {{ ucfirst($t['sender']->role ?? 'user') }}{{ $t['total'] > 1 ? ' · '.$t['total'].' msgs' : '' }} · {{ $t['latest']->created_at->diffForHumans() }} @if($showInboxSchool && isset($inboxSchoolMap[$t['sender']->school_id ?? null])) {{ $inboxSchoolMap[$t['sender']->school_id] }} @endif {{ \Illuminate\Support\Str::limit($t['latest']->body, 42) }} @if($t['unread'] > 0) {{ $t['unread'] }} @endif @empty

Inbox is clear

Messages from other users will appear here.

@endforelse
{{-- Right: opened message --}}
@if(isset($selected) && $selected)
{{ $selected->subject ?: '(No subject)' }}

With {{ $selected->sender_id === auth()->id() ? ($selected->recipient->name ?? 'User') : ($selected->sender->name ?? 'User') }} · started {{ $selected->created_at->format('d M Y H:i') }}

@foreach ($thread as $m) @php $mine = $m->sender_id === auth()->id(); @endphp
{{ $m->sender->name ?? 'User' }} · {{ $m->created_at->format('d M H:i') }}
{{ $m->body }}
@if($m->has_attachment) @endif
@endforeach
@csrf
@else

Select a conversation

Choose a sender on the left to read and reply —
unread counts show per person.

New Message
@endif
Compose
@endsection @push('scripts') @endpush