@extends('layouts.app') @section('title', 'Chat with ' . ($otherUser->name ?? 'Unknown')) @section('page-title', 'Messages') @section('content')
{{-- Chat Header --}}
{{ strtoupper(substr($otherUser->name ?? '?', 0, 1)) }}{{ strtoupper(substr(explode(' ', $otherUser->name ?? '')[1] ?? '', 0, 1)) }}

{{ $otherUser->name ?? 'Unknown' }}

{{ $otherUser->role ?? '' }}
@if(!empty($otherUserInfo))

@if($otherUser->role === 'parent') @elseif($otherUser->role === 'student') @elseif($otherUser->role === 'teacher') @endif {{ $otherUserInfo }}

@endif
{{-- Messages Area --}}
@if($messages->hasMorePages()) @endif @foreach($messages->reverse() as $msg) @php $isMine = $msg->sender_id === auth()->id(); @endphp
@if(!$isMine)

{{ $msg->sender->name ?? 'Unknown' }}

@endif

{{ $msg->message }}

@if($msg->attachment) Attachment @endif

{{ $msg->created_at->format('h:i A') }} ยท {{ $msg->created_at->format('d M') }}

@endforeach @if($messages->isEmpty())

No messages yet. Say hello!

@endif
{{-- Message Input --}}
@csrf
@endsection