--- /dev/null
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\SitemapUrl;
+use App\Models\Tournament;
+use Illuminate\Http\Request;
+
+class SitemapXmlController extends Controller
+{
+
+ public function index() {
+ $urls = [];
+
+ foreach (Tournament::all() as $tournament) {
+ $url = new SitemapUrl();
+ $url->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');
+ }
+
+}
--- /dev/null
+<?php
+
+namespace App\Models;
+
+class SitemapUrl {
+
+ public $path = '';
+ public $lastmod = null;
+ public $changefreq = 'never';
+ public $priority = 0.0;
+
+}
--- /dev/null
+<?php echo '<?xml version="1.0" encoding="UTF-8"?>', "\n"; ?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+@foreach ($urls as $url)
+ <url>
+ <loc>{{ url($url->path) }}</loc>
+ <lastmod>{{ $url->lastmod->tz('UTC')->toAtomString() }}</lastmod>
+ <changefreq>{{ $url->changefreq }}</changefreq>
+ <priority>{{ $url->priority }}</priority>
+ </url>
+@endforeach
+</urlset>
<?php
use App\Http\Controllers\DiscordController;
+use App\Http\Controllers\SitemapXmlController;
use Illuminate\Support\Facades\Route;
/*
|
*/
+Route::get('/sitemap.xml', [SitemapXmlController::class, 'index']);
+
Route::view('/{path?}', 'app')->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');
});