published() ->where('published_at', '>=', now()->subHours(max(1, (int) \config('sitemaps.news.google_lookback_hours', 48)))) ->orderByDesc('published_at') ->limit(max(1, (int) \config('sitemaps.news.google_max_items', 1000))) ->get() ->map(function (NewsArticle $article): ?GoogleNewsSitemapUrl { if (trim((string) $article->slug) === '' || $article->published_at === null) { return null; } return new GoogleNewsSitemapUrl( route('news.show', ['slug' => $article->slug]), trim((string) $article->title), $article->published_at, (string) \config('sitemaps.news.google_publication_name', 'Skinbase Nova'), (string) \config('sitemaps.news.google_language', 'en'), ); }) ->filter(fn (?GoogleNewsSitemapUrl $item): bool => $item !== null && $item->title !== '') ->values() ->all(); } public function lastModified(): ?DateTimeInterface { return $this->dateTime(NewsArticle::query() ->published() ->where('published_at', '>=', now()->subHours(max(1, (int) \config('sitemaps.news.google_lookback_hours', 48)))) ->max('published_at')); } }