3 namespace App\Http\Controllers;
5 use App\Models\SitemapUrl;
6 use App\Models\Technique;
7 use App\Models\Tournament;
8 use Illuminate\Http\Request;
10 class SitemapXmlController extends Controller
13 public function index() {
16 foreach (Tournament::all() as $tournament) {
17 $url = new SitemapUrl();
18 $url->path = '/tournaments/'.$tournament->id;
19 $url->lastmod = $tournament->updated_at ? $tournament->updated_at : ($tournament->created_at ? $tournament->created_at : now());
20 $url->changefreq = $tournament->locked ? 'never' : 'daily';
21 $url->priority = $tournament->locked ? 0.5 : 1.0;
25 $url = new SitemapUrl();
27 $url->lastmod = Technique::where('type', '=', 'tech')->where('index', true)->latest()->first()->created_at;
28 $url->changefreq = 'monthly';
32 foreach (Technique::where('type', '=', 'tech')->where('index', true)->get() as $tech) {
33 $url = new SitemapUrl();
34 $url->path = '/tech/'.rawurlencode($tech->name);
35 $url->lastmod = $tech->updated_at ? $tech->updated_at : ($tech->created_at ? $tech->created_at : now());
36 $url->changefreq = 'never';
37 $url->priority = $tech->priority;
41 return response()->view('sitemap', [
43 ])->header('Content-Type', 'text/xml');