Explorar el Código

feat:add new files

igb hace 5 meses
padre
commit
67c602ce26
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  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);