@extends('layouts.teacher')
@section('title', 'Messages')
@section('content')
    <x-page-head title="Messages" subtitle="Inbox & sent">
        <x-slot:actions><a href="{{ route('teacher.messages.create') }}" class="btn btn-primary">Compose</a></x-slot:actions>
    </x-page-head>
    <x-panel>
        <h3 style="margin-bottom:12px;">Inbox</h3>
        @if ($inbox->isEmpty())
            <x-empty-state title="No messages" message="Your inbox is empty." />
        @else
            <div class="table-wrap"><table><thead><tr><th>From</th><th>Subject</th><th>Date</th><th>Read</th></tr></thead><tbody>
                @foreach ($inbox as $item)
                    <tr>
                        <td>{{ $item->message?->sender?->name }}</td>
                        <td><a href="{{ route('teacher.messages.show', $item) }}">{{ $item->message?->subject }}</a></td>
                        <td>{{ $item->message?->sent_at?->format('M j, Y') }}</td>
                        <td>{{ $item->read_at ? 'Yes' : 'No' }}</td>
                    </tr>
                @endforeach
            </tbody></table></div>
            <div style="margin-top:16px;">{{ $inbox->links() }}</div>
        @endif
    </x-panel>
@endsection
