From: Daniel Karbach Date: Thu, 31 Mar 2022 14:45:50 +0000 (+0200) Subject: sitemap xml controller X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=6609e9cbc3c9d3f9a7f0b2db9d8407f56957cef5;p=alttp.git sitemap xml controller --- diff --git a/app/Http/Controllers/SitemapXmlController.php b/app/Http/Controllers/SitemapXmlController.php new file mode 100644 index 0000000..35302c4 --- /dev/null +++ b/app/Http/Controllers/SitemapXmlController.php @@ -0,0 +1,29 @@ +path = '/tournaments'.$tournament->id; + $url->lastmod = $tournament->updated_at ? $tournament->updated_at : ($tournament->created_at ? $tournament->created_at : now()); + $url->changefreq = $tournament->locked ? 'never' : 'daily'; + $url->priority = $tournament->locked ? 0.5 : 1.0; + $urls[] = $url; + } + + return response()->view('sitemap', [ + 'urls' => $urls, + ])->header('Content-Type', 'text/xml'); + } + +} diff --git a/app/Models/SitemapUrl.php b/app/Models/SitemapUrl.php new file mode 100644 index 0000000..0d542a5 --- /dev/null +++ b/app/Models/SitemapUrl.php @@ -0,0 +1,12 @@ +', "\n"; ?> + +@foreach ($urls as $url) + + {{ url($url->path) }} + {{ $url->lastmod->tz('UTC')->toAtomString() }} + {{ $url->changefreq }} + {{ $url->priority }} + +@endforeach + diff --git a/routes/web.php b/routes/web.php index 903ca72..450d21f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ where('path', '.*'); Route::group(['prefix' => config('larascord.prefix'), 'middleware' => ['web']], function() { - Route::get('/callback', [DiscordController::class, 'handle']) - ->name('larascord.login'); + Route::get('/callback', [DiscordController::class, 'handle']) + ->name('larascord.login'); - Route::redirect('/refresh-token', '/login') - ->name('larascord.refresh_token'); + Route::redirect('/refresh-token', '/login') + ->name('larascord.refresh_token'); });