first commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user