@php use App\Addons\Announcements\Models\Announcement; use App\Addons\Announcements\Models\AnnouncementCategory; $limit = $limit ?? 5; $category = $category ?? null; $featuredOnly = $featuredOnly ?? false; $showViewAll = $showViewAll ?? true; $query = Announcement::published()->with('category')->ordered(); if ($featuredOnly) { $query->featured(); } if ($category) { $categoryModel = AnnouncementCategory::where('slug', $category)->first(); if ($categoryModel) { $query->where('category_id', $categoryModel->id); } } $announcements = $query->limit($limit)->get(); @endphp @if($announcements->count() > 0)

{{ __('announcements::messages.components.latest.title') }}

@if($showViewAll) {{ __('announcements::messages.components.latest.view_all') }} → @endif
@foreach($announcements as $announcement) @if($announcement->cover_image_display_url) @else
@endif
@if($announcement->category) {{ $announcement->category->name }} @endif @if($announcement->featured) @endif

{{ $announcement->title }}

{{ $announcement->published_at?->diffForHumans() }}

@endforeach
@else

{{ __('announcements::messages.components.latest.no_announcements') }}

@endif