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 $url = new SitemapUrl();
28 $url->lastmod = TechniqueMap::latest()->first()->created_at;
29 $url->changefreq = 'monthly';
33 $url = new SitemapUrl();
35 $url->lastmod = Technique::where('type', '=', 'tech')->where('index', true)->latest()->first()->created_at;
36 $url->changefreq = 'monthly';
40 foreach (Technique::where('type', '=', 'tech')->where('index', true)->get() as $tech) {
41 $url = new SitemapUrl();
42 $url->path = '/tech/'.rawurlencode($tech->name);
43 $url->lastmod = $tech->updated_at ? $tech->updated_at : ($tech->created_at ? $tech->created_at : now());
44 $url->changefreq = 'never';
45 $url->priority = $tech->priority;
49 return response()->view('sitemap', [
51 ])->header('Content-Type', 'text/xml');