3 namespace App\Http\Controllers;
5 use App\Models\SitemapUrl;
6 use App\Models\Technique;
7 use App\Models\TechniqueMap;
8 use App\Models\Tournament;
9 use Illuminate\Http\Request;
11 class SitemapXmlController extends Controller
14 public function index() {
17 foreach (Tournament::all() as $tournament) {
18 $url = new SitemapUrl();
19 $url->path = '/tournaments/'.$tournament->id;
20 $url->lastmod = $tournament->updated_at ? $tournament->updated_at : ($tournament->created_at ? $tournament->created_at : now());
21 $url->changefreq = $tournament->locked ? 'never' : 'daily';
22 $url->priority = $tournament->locked ? 0.5 : 1.0;
26 foreach (['lw', 'dw', 'sp', 'uw', 'uw2'] as $map) {
27 $tech = TechniqueMap::where('map', '=', $map)->latest()->first();
28 $url = new SitemapUrl();
29 $url->path = '/map/'.$map;
31 $url->lastmod = $tech->created_at;
33 $url->changefreq = 'monthly';
38 $url = new SitemapUrl();
40 $url->lastmod = Technique::where('type', '=', 'tech')->where('index', true)->latest()->first()->created_at;
41 $url->changefreq = 'monthly';
45 foreach (Technique::where('type', '=', 'tech')->where('index', true)->get() as $tech) {
46 $url = new SitemapUrl();
47 $url->path = '/tech/'.rawurlencode($tech->name);
48 $url->lastmod = $tech->updated_at ? $tech->updated_at : ($tech->created_at ? $tech->created_at : now());
49 $url->changefreq = 'never';
50 $url->priority = $tech->priority;
54 return response()->view('sitemap', [
56 ])->header('Content-Type', 'text/xml');