Browse Source

feat:add new files

igb 5 months ago
parent
commit
67c602ce26
1 changed files with 8 additions and 2 deletions
  1. 8 2
      app/Http/Controllers/CollectionController.php

+ 8 - 2
app/Http/Controllers/CollectionController.php

@@ -32,8 +32,14 @@ class CollectionController extends Controller
     {
 
 
-        // 查找对应的 tag
-        $tag = SitePageTag::where('slug', $slug)->first();
+        // Check if the $slug is numeric (ID), if so, fetch by ID
+        if (is_numeric($slug)) {
+            $tag = SitePageTag::find($slug);  // Find by ID
+        } else {
+            // Otherwise, find by slug
+            $tag = SitePageTag::where('slug', $slug)->first();
+        }
+
 
         if (!$tag) {
             return response()->json(['message' => '标签未找到'], 404);