@extends('layouts.app')

@section('title','Notifications')
@section('header','Notifications')

@section('content')
<div class="panel">
    <h1>Notifications</h1>
    <table>
        <tr><th>Notification</th><th>Type</th><th>Date</th><th></th></tr>
        @forelse($notifications as $notification)
            <tr>
                <td>
                    <strong>{{ $notification->title }}</strong><br>
                    <span class="muted">{{ $notification->message }}</span>
                </td>
                <td>{{ $notification->type }}</td>
                <td>{{ $notification->created_at->format('d M Y H:i') }}</td>
                <td>
                    @if(!$notification->read_at)
                        <form method="post" action="{{ route('notifications.read',$notification) }}">
                            @csrf
                            <button class="btn">Mark read</button>
                        </form>
                    @else
                        Read
                    @endif
                </td>
            </tr>
        @empty
            <tr><td colspan="4">No notifications.</td></tr>
        @endforelse
    </table>
    {{ $notifications->links() }}
</div>
@endsection
