<?phpdeclare(strict_types=1)namespaceApp\Http\Controllers;useApp\Models\Post;useIlluminate\Http\Response;classSitemapPostsIndexControllerextendsController{publicfunction__invoke():Response{$months=Post::selectRaw('DATE_FORMAT(`published_at`, "%Y-%m") AS `date`, MAX(`published_at`) AS `published_at`')->groupBy('date')->get();returnresponse()->view('sitemap.posts.index',['months'=>$months,])->header('Content-Type','text/xml');}}
The idea is great!
Here my version with months instead alphabet:
Thanks for sharing!
I really like your method! Thank you!