X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FHttp%2FControllers%2FSitemapXmlController.php;h=c538bc447be7cfad8de6b462a89871a5b4e11277;hb=147c5f43c5d41fa18e82edb6651fe5a37c789353;hp=ebb7b621a15c64230504bcdb70d4f748b1071dd5;hpb=4ac9a5a331949fcec42378ddc495385ae8628a79;p=alttp.git diff --git a/app/Http/Controllers/SitemapXmlController.php b/app/Http/Controllers/SitemapXmlController.php index ebb7b62..c538bc4 100644 --- a/app/Http/Controllers/SitemapXmlController.php +++ b/app/Http/Controllers/SitemapXmlController.php @@ -2,8 +2,11 @@ namespace App\Http\Controllers; +use App\Models\Episode; +use App\Models\Event; use App\Models\SitemapUrl; use App\Models\Technique; +use App\Models\TechniqueMap; use App\Models\Tournament; use Illuminate\Http\Request; @@ -22,15 +25,57 @@ class SitemapXmlController extends Controller $urls[] = $url; } - foreach (Technique::where('index', true)->get() as $tech) { + 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'; + $url->lastmod = Technique::where('type', '=', 'tech')->where('index', true)->latest()->first()->created_at; + $url->changefreq = 'monthly'; + $url->priority = 0.8; + $urls[] = $url; + + foreach (Technique::where('type', '=', 'tech')->where('index', true)->get() as $tech) { $url = new SitemapUrl(); $url->path = '/tech/'.rawurlencode($tech->name); $url->lastmod = $tech->updated_at ? $tech->updated_at : ($tech->created_at ? $tech->created_at : now()); - $url->changefreq = 'monthly'; + $url->changefreq = 'never'; $url->priority = $tech->priority; $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');