Notifications

@php use Carbon\Carbon; $today = Carbon::today(); $yesterday = Carbon::yesterday(); // Categorizing notifications $todayNotifications = $notifications->filter(fn($n) => Carbon::parse($n->created_at)->isToday()); $yesterdayNotifications = $notifications->filter( fn($n) => Carbon::parse($n->created_at)->isYesterday(), ); $otherNotifications = $notifications->filter( fn($n) => !Carbon::parse($n->created_at)->isToday() && !Carbon::parse($n->created_at)->isYesterday(), ); @endphp

Today

    @forelse ($todayNotifications as $notification)
  • {{ $notification->notice }}

    {{--

    {{ $notification->message }}

    --}} Date: {{ Carbon::parse($notification->created_at)->format('h:i A') }} || {{ Carbon::parse($notification->created_at)->format('d-m-Y') }} ||
  • @empty

    No Today Notifications

    @endforelse

Yesterday

    @forelse ($yesterdayNotifications as $notification)
  • {{ $notification->notice }}

    {{--

    {{ $notification->message }}

    --}} Date: {{ Carbon::parse($notification->created_at)->format('h:i A') }} || {{ Carbon::parse($notification->created_at)->format('d-m-Y') }} ||
  • @empty

    No Yesterday Notifications

    @endforelse

Others

    @forelse ($otherNotifications as $notification)
  • {{ $notification->notice }}

    {{--

    {{ $notification->message }}

    --}} Date: {{ Carbon::parse($notification->created_at)->format('h:i A') }} || {{ Carbon::parse($notification->created_at)->format('d-m-Y') }} ||
  • @empty

    No Other Notifications

    @endforelse