['title' => 'Latest Uploads', 'url' => '/rss/latest-uploads.xml'], 'skins' => ['title' => 'Latest Skins', 'url' => '/rss/latest-skins.xml'], 'wallpapers' => ['title' => 'Latest Wallpapers', 'url' => '/rss/latest-wallpapers.xml'], 'photos' => ['title' => 'Latest Photos', 'url' => '/rss/latest-photos.xml'], ]; /** Info page at /rss-feeds */ public function index(): View { return view('web.rss-feeds', [ 'page_title' => 'RSS Feeds — Skinbase', 'page_meta_description' => 'Subscribe to Skinbase RSS feeds to stay up to date with the latest uploads, skins, wallpapers, and photos.', 'page_canonical' => url('/rss-feeds'), 'hero_title' => 'RSS Feeds', 'hero_description' => 'Subscribe to stay up to date with the latest content on Skinbase.', 'breadcrumbs' => collect([ (object) ['name' => 'Home', 'url' => '/'], (object) ['name' => 'RSS Feeds', 'url' => '/rss-feeds'], ]), 'feeds' => self::FEEDS, 'center_content' => true, 'center_max' => '3xl', ]); } /** /rss/latest-uploads.xml — all content types */ public function latestUploads(): Response { $artworks = Artwork::published() ->with(['user']) ->latest('published_at') ->limit(self::FEED_LIMIT) ->get(); return $this->buildFeed('Latest Uploads', url('/rss/latest-uploads.xml'), $artworks); } /** /rss/latest-skins.xml */ public function latestSkins(): Response { return $this->feedByContentType('skins', 'Latest Skins', '/rss/latest-skins.xml'); } /** /rss/latest-wallpapers.xml */ public function latestWallpapers(): Response { return $this->feedByContentType('wallpapers', 'Latest Wallpapers', '/rss/latest-wallpapers.xml'); } /** /rss/latest-photos.xml */ public function latestPhotos(): Response { return $this->feedByContentType('photography', 'Latest Photos', '/rss/latest-photos.xml'); } // ------------------------------------------------------------------------- private function feedByContentType(string $slug, string $title, string $feedPath): Response { $contentType = ContentType::where('slug', $slug)->first(); $query = Artwork::published()->with(['user'])->latest('published_at')->limit(self::FEED_LIMIT); if ($contentType) { $query->whereHas('categories', fn ($q) => $q->where('content_type_id', $contentType->id)); } return $this->buildFeed($title, url($feedPath), $query->get()); } private function buildFeed(string $channelTitle, string $feedUrl, $artworks): Response { $content = view('rss.feed', [ 'channelTitle' => $channelTitle . ' — Skinbase', 'channelDescription' => 'The latest ' . strtolower($channelTitle) . ' from Skinbase.org', 'channelLink' => url('/'), 'feedUrl' => $feedUrl, 'artworks' => $artworks, 'buildDate' => now()->toRfc2822String(), ])->render(); return response($content, 200, [ 'Content-Type' => 'application/rss+xml; charset=utf-8', ]); } }