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 foreach (Technique::where('index', true)->get() as $tech) {
26 $url = new SitemapUrl();
27 $url->path = '/tech/'.rawurlencode($tech->name);
28 $url->lastmod = $tech->updated_at ? $tech->updated_at : ($tech->created_at ? $tech->created_at : now());
29 $url->changefreq = 'monthly';
30 $url->priority = $tech->priority;
34 return response()->view('sitemap', [
36 ])->header('Content-Type', 'text/xml');