]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/SitemapXmlController.php
events overview
[alttp.git] / app / Http / Controllers / SitemapXmlController.php
index 99e909212f2bbced0371e0b9c01f9f6ea9e00684..c538bc447be7cfad8de6b462a89871a5b4e11277 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\Episode;
+use App\Models\Event;
 use App\Models\SitemapUrl;
 use App\Models\Technique;
 use App\Models\TechniqueMap;
@@ -23,12 +25,17 @@ class SitemapXmlController extends Controller
                        $urls[] = $url;
                }
 
-               $url = new SitemapUrl();
-               $url->path = '/map';
-               $url->lastmod = TechniqueMap::latest()->first()->created_at;
-               $url->changefreq = 'monthly';
-               $url->priority = 0.9;
-               $urls[] = $url;
+               foreach (['lw', 'dw', 'sp', 'uw', 'uw2'] as $map) {
+                       $tech = TechniqueMap::where('map', '=', $map)->latest()->first();
+                       $url = new SitemapUrl();
+                       $url->path = '/map/'.$map;
+                       if ($tech) {
+                               $url->lastmod = $tech->created_at;
+                       }
+                       $url->changefreq = 'monthly';
+                       $url->priority = 0.9;
+                       $urls[] = $url;
+               }
 
                $url = new SitemapUrl();
                $url->path = '/tech';
@@ -46,6 +53,29 @@ class SitemapXmlController extends Controller
                        $urls[] = $url;
                }
 
+               $url = new SitemapUrl();
+               $url->path = '/schedule';
+               $url->lastmod = Episode::where('confirmed', true)->latest()->first()->created_at;
+               $url->changefreq = 'daily';
+               $url->priority = 1;
+               $urls[] = $url;
+
+               $url = new SitemapUrl();
+               $url->path = '/events';
+               $url->lastmod = Event::where('visible', true)->latest()->first()->created_at;
+               $url->changefreq = 'monthly';
+               $url->priority = 0.8;
+               $urls[] = $url;
+
+               foreach (Event::where('visible', true)->get() as $event) {
+                       $url = new SitemapUrl();
+                       $url->path = '/events/'.rawurlencode($event->name);
+                       $url->lastmod = $event->updated_at ? $event->updated_at : ($event->created_at ? $event->created_at : now());
+                       $url->changefreq = 'never';
+                       $url->priority = 0.4;
+                       $urls[] = $url;
+               }
+
                return response()->view('sitemap', [
                        'urls' => $urls,
                ])->header('Content-Type', 'text/xml');