From: Daniel Karbach Date: Fri, 19 Aug 2022 08:23:59 +0000 (+0200) Subject: add index option for tech sites X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=4ac9a5a331949fcec42378ddc495385ae8628a79;p=alttp.git add index option for tech sites --- diff --git a/app/Http/Controllers/SitemapXmlController.php b/app/Http/Controllers/SitemapXmlController.php index 03a41c4..ebb7b62 100644 --- a/app/Http/Controllers/SitemapXmlController.php +++ b/app/Http/Controllers/SitemapXmlController.php @@ -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'); diff --git a/app/Models/Technique.php b/app/Models/Technique.php index 202c455..2caa5f3 100644 --- a/app/Models/Technique.php +++ b/app/Models/Technique.php @@ -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 index 0000000..d1b6d6e --- /dev/null +++ b/database/migrations/2022_08_19_080601_tech_index.php @@ -0,0 +1,34 @@ +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'); + }); + } +};