]> git.localhorst.tv Git - alttp.git/commitdiff
expand tech
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 5 Jan 2023 18:52:12 +0000 (19:52 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 5 Jan 2023 18:52:12 +0000 (19:52 +0100)
app/Http/Controllers/SitemapXmlController.php
app/Http/Controllers/TechniqueController.php
database/migrations/2023_01_05_172332_tech_type.php [new file with mode: 0644]
resources/js/components/pages/Techniques.js

index 1bd7749589507c3b5aad322bb2b914848a3cc097..daa3699b714d72fd4f8ee4a9e6edcbdfe5896546 100644 (file)
@@ -24,12 +24,12 @@ class SitemapXmlController extends Controller
 
                $url = new SitemapUrl();
                $url->path = '/tech';
-               $url->lastmod = Technique::latest()->first()->created_at;
+               $url->lastmod = Technique::where('type', '=', 'tech')->where('index', true)->latest()->first()->created_at;
                $url->changefreq = 'monthly';
                $url->priority = 0.5;
                $urls[] = $url;
 
-               foreach (Technique::where('index', true)->get() as $tech) {
+               foreach (Technique::where('type', '=', 'tech')->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());
index a1ba20e59ac214877b46d815bcd6084d150a7df0..268c3f6abeff765568efd68209edc79942363c81 100644 (file)
@@ -12,10 +12,15 @@ class TechniqueController extends Controller
        public function search(Request $request) {
                $validatedData = $request->validate([
                        'phrase' => 'string|nullable',
+                       'type' => 'string|nullable',
                ]);
 
                $techs = Technique::where('index', '=', 1);
 
+               if (!empty($validatedData['type'])) {
+                       $techs = $techs->where('type', '=', $validatedData['type']);
+               }
+
                if (!empty($validatedData['phrase'])) {
                        $search = $validatedData['phrase'];
                        $techs = $techs->where(function (Builder $query) use ($search) {
diff --git a/database/migrations/2023_01_05_172332_tech_type.php b/database/migrations/2023_01_05_172332_tech_type.php
new file mode 100644 (file)
index 0000000..6d9577a
--- /dev/null
@@ -0,0 +1,32 @@
+<?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->string('type')->default('tech');
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('techniques', function(Blueprint $table) {
+                       $table->dropColumn('type');
+               });
+       }
+};
index 9334155a92ae284310726e8baa650d7f6e4592e7..c206a31b6fbb9bd33252054e977369b008667a15 100644 (file)
@@ -20,7 +20,12 @@ const Techniques = () => {
                setLoading(true);
                window.document.title = i18n.t('techniques.heading');
                axios
-                       .get(`/api/tech`, { signal: ctrl.signal })
+                       .get(`/api/tech`, {
+                               params: {
+                                       type: 'tech',
+                               },
+                               signal: ctrl.signal
+                       })
                        .then(response => {
                                setError(null);
                                setLoading(false);