2022-09-20 19:59:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2022-10-02 18:38:41 +00:00
|
|
|
use App\Models\Template;
|
2024-02-23 10:54:12 +00:00
|
|
|
use Illuminate\Http\Request;
|
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 [
|
2024-02-23 10:54:12 +00:00
|
|
|
...$this->getTemplatesUrls(),
|
2024-01-02 18:03:14 +00:00
|
|
|
];
|
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[] = [
|
2024-02-23 10:54:12 +00:00
|
|
|
'loc' => '/templates/'.$template->slug,
|
2024-01-02 18:03:14 +00:00
|
|
|
];
|
2022-10-02 18:38:41 +00:00
|
|
|
}
|
|
|
|
});
|
2024-02-23 10:54:12 +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
|
|
|
}
|