]> git.localhorst.tv Git - alttp.git/blob - app/Http/Controllers/SitemapXmlController.php
remove alttp-seeds storage link from version control
[alttp.git] / app / Http / Controllers / SitemapXmlController.php
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use App\Models\SitemapUrl;
6 use App\Models\Tournament;
7 use Illuminate\Http\Request;
8
9 class SitemapXmlController extends Controller
10 {
11
12         public function index() {
13                 $urls = [];
14
15                 foreach (Tournament::all() as $tournament) {
16                         $url = new SitemapUrl();
17                         $url->path = '/tournaments/'.$tournament->id;
18                         $url->lastmod = $tournament->updated_at ? $tournament->updated_at : ($tournament->created_at ? $tournament->created_at : now());
19                         $url->changefreq = $tournament->locked ? 'never' : 'daily';
20                         $url->priority = $tournament->locked ? 0.5 : 1.0;
21                         $urls[] = $url;
22                 }
23
24                 return response()->view('sitemap', [
25                         'urls' => $urls,
26                 ])->header('Content-Type', 'text/xml');
27         }
28
29 }