Files
omg-wtf-ai/app/Http/Controllers/SitemapController.php
T

35 lines
1010 B
PHP
Raw Normal View History

2026-08-08 18:03:29 +03:00
<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Page;
use App\Models\Post;
use App\Models\Tag;
use App\Models\Tool;
use Illuminate\Http\Response;
class SitemapController extends Controller
{
public function index(): Response
{
$posts = Post::published()->get(['slug', 'updated_at']);
$categories = Category::all(['slug', 'updated_at']);
$tags = Tag::all(['slug', 'updated_at']);
$tools = Tool::approved()->get(['slug', 'updated_at']);
$toolCategories = array_keys(config('tools.categories'));
$pages = Page::published()->get(['slug', 'updated_at']);
$xml = view('sitemap', [
'posts' => $posts,
'categories' => $categories,
'tags' => $tags,
'tools' => $tools,
'toolCategories' => $toolCategories,
'pages' => $pages,
])->render();
return response($xml, 200)->header('Content-Type', 'application/xml; charset=UTF-8');
}
}