2022-09-20 19:59:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Spatie\Sitemap\Sitemap;
|
|
|
|
use Spatie\Sitemap\Tags\Url;
|
2022-10-02 18:38:41 +00:00
|
|
|
use App\Models\Template;
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
class SitemapController extends Controller
|
|
|
|
{
|
|
|
|
|
2024-01-02 18:03:14 +00:00
|
|
|
public function index(Request $request)
|
2022-09-20 19:59:52 +00:00
|
|
|
{
|
2024-01-02 18:03:14 +00:00
|
|
|
return [
|
|
|
|
...$this->getTemplatesUrls()
|
|
|
|
];
|
2022-09-20 19:59:52 +00:00
|
|
|
}
|
|
|
|
|
2024-01-02 18:03:14 +00:00
|
|
|
private function getTemplatesUrls()
|
2022-09-20 19:59:52 +00:00
|
|
|
{
|
2024-01-02 18:03:14 +00:00
|
|
|
$urls = [];
|
|
|
|
Template::where('publicly_listed', true)->chunk(100, function ($templates) use (&$urls) {
|
2022-10-02 18:38:41 +00:00
|
|
|
foreach ($templates as $template) {
|
2024-01-02 18:03:14 +00:00
|
|
|
$urls[] = [
|
|
|
|
'loc' => '/templates/' . $template->slug
|
|
|
|
];
|
2022-10-02 18:38:41 +00:00
|
|
|
}
|
|
|
|
});
|
2024-01-02 18:03:14 +00:00
|
|
|
return $urls;
|
2023-10-24 18:55:15 +00:00
|
|
|
}
|
2022-09-20 19:59:52 +00:00
|
|
|
}
|