opnform/app/Http/Controllers/SitemapController.php

31 lines
643 B
PHP
Raw Normal View History

2022-09-20 19:59:52 +00:00
<?php
namespace App\Http\Controllers;
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
{
public function index(Request $request)
2022-09-20 19:59:52 +00:00
{
return [
2024-02-23 10:54:12 +00:00
...$this->getTemplatesUrls(),
];
2022-09-20 19:59:52 +00:00
}
private function getTemplatesUrls()
2022-09-20 19:59:52 +00:00
{
$urls = [];
Template::where('publicly_listed', true)->chunk(100, function ($templates) use (&$urls) {
foreach ($templates as $template) {
$urls[] = [
2024-02-23 10:54:12 +00:00
'loc' => '/templates/'.$template->slug,
];
}
});
2024-02-23 10:54:12 +00:00
return $urls;
}
2022-09-20 19:59:52 +00:00
}