@extends('admin.layout')

@section('title', 'Messages contact')

@section('content')
    <h1>Messages contact</h1>
    <p class="muted">Demandes envoyees depuis le formulaire du site.</p>

    <div class="card" style="padding:0;overflow:hidden;">
        <table>
            <thead>
                <tr>
                    <th>Date</th>
                    <th>Nom</th>
                    <th>Email</th>
                    <th>Besoin</th>
                    <th>Lu</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @forelse($messages as $msg)
                    <tr>
                        <td>{{ $msg->created_at->format('d/m/Y H:i') }}</td>
                        <td>{{ $msg->name }}</td>
                        <td>{{ $msg->email }}</td>
                        <td><span class="pill">{{ $msg->besoin }}</span></td>
                        <td>{{ $msg->read_at ? $msg->read_at->format('d/m/Y') : '—' }}</td>
                        <td><a href="{{ route('admin.contact-messages.show', $msg) }}">Ouvrir</a></td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="6" style="color:#5f6b76;">Aucun message.</td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    <div style="margin-top:20px;">{{ $messages->links() }}</div>
@endsection
