@extends('layouts.app')
@section('title', __('Notifications'))
@section('page-title', 'Notifications')
@section('page-subtitle', 'Everything that happened in your space')
@section('content')
{{ auth()->user()->unreadNotifications()->count() }} unread of {{ $notifications->total() }}
@if(auth()->user()->unreadNotifications()->exists())
@endif
@php
$tones = [
'success' => 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300',
'warning' => 'bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300',
'error' => 'bg-rose-100 text-rose-700 dark:bg-rose-900/40 dark:text-rose-300',
'info' => 'bg-brand-100 text-brand-700 dark:bg-brand-900/40 dark:text-brand-300',
];
$rows = $notifications->map(function ($n) use ($tones) {
$level = $n->data['level'] ?? 'info';
return [
'n' => $n,
'tone' => $tones[$level] ?? $tones['info'],
'icon' => $n->data['icon'] ?? 'bell',
'href' => $n->data['url'] ?? null,
'title' => $n->data['title'] ?? __('Notification'),
'msg' => $n->data['message'] ?? '',
];
});
@endphp
@forelse($rows as $row)
@if($row['href'])
{{ $row['title'] }}
@else
{{ $row['title'] }}
@endif
@if(! $row['n']->read_at)
{{ __('new') }}@endif
{{ $row['msg'] }}
{{ $row['n']->created_at?->diffForHumans() }}
@if(! $row['n']->read_at)
@endif
@empty
@endforelse
{{ $notifications->links() }}
@endsection