3 namespace App\Http\Controllers;
5 use App\Models\SitemapUrl;
6 use App\Models\Tournament;
7 use Illuminate\Http\Request;
9 class SitemapXmlController extends Controller
12 public function index() {
15 foreach (Tournament::all() as $tournament) {
16 $url = new SitemapUrl();
17 $url->path = '/tournaments/'.$tournament->id;
18 $url->lastmod = $tournament->updated_at ? $tournament->updated_at : ($tournament->created_at ? $tournament->created_at : now());
19 $url->changefreq = $tournament->locked ? 'never' : 'daily';
20 $url->priority = $tournament->locked ? 0.5 : 1.0;
24 return response()->view('sitemap', [
26 ])->header('Content-Type', 'text/xml');