]> git.localhorst.tv Git - alttp.git/commitdiff
add index option for tech sites
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 19 Aug 2022 08:23:59 +0000 (10:23 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 19 Aug 2022 08:23:59 +0000 (10:23 +0200)
app/Http/Controllers/SitemapXmlController.php
app/Models/Technique.php
database/migrations/2022_08_19_080601_tech_index.php [new file with mode: 0644]

index 03a41c485e080c3f12351ef06df5ad00920277ed..ebb7b621a15c64230504bcdb70d4f748b1071dd5 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\SitemapUrl;
+use App\Models\Technique;
 use App\Models\Tournament;
 use Illuminate\Http\Request;
 
@@ -21,6 +22,15 @@ class SitemapXmlController extends Controller
                        $urls[] = $url;
                }
 
+               foreach (Technique::where('index', true)->get() as $tech) {
+                       $url = new SitemapUrl();
+                       $url->path = '/tech/'.rawurlencode($tech->name);
+                       $url->lastmod = $tech->updated_at ? $tech->updated_at : ($tech->created_at ? $tech->created_at : now());
+                       $url->changefreq = 'monthly';
+                       $url->priority = $tech->priority;
+                       $urls[] = $url;
+               }
+
                return response()->view('sitemap', [
                        'urls' => $urls,
                ])->header('Content-Type', 'text/xml');
index 202c455945736ae2107ff21bbd4ce594ade2ccaa..2caa5f320650d296d31d9bbdb0bf6ffbe8e9cbf5 100644 (file)
@@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
 class Technique extends Model
 {
        use HasFactory;
+
+       protected $casts = [
+               'index' => 'boolean',
+       ];
 }
diff --git a/database/migrations/2022_08_19_080601_tech_index.php b/database/migrations/2022_08_19_080601_tech_index.php
new file mode 100644 (file)
index 0000000..d1b6d6e
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::table('techniques', function(Blueprint $table) {
+                       $table->boolean('index')->default(false);
+                       $table->float('priority')->default(0.5);
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('rounds', function(Blueprint $table) {
+                       $table->dropColumn('index');
+                       $table->dropColumn('priority');
+               });
+       }
+};