peterguo před 3 týdny
rodič
revize
0063d9b92e
1 změnil soubory, kde provedl 14 přidání a 10 odebrání
  1. 14 10
      app/Http/Controllers/API/FileController.php

+ 14 - 10
app/Http/Controllers/API/FileController.php

@@ -356,16 +356,20 @@ class FileController extends Controller
 
         $file = File::query()->findOrFail($fileId);
 
-        $files = File::query()
-            ->with(['bimFile', 'createdBy'])
-            ->where('is_bim', 1)
-            ->where('object_type', $file->object_type)
-            ->where('object_id', $file->object_id)
-            ->where('folder_id', $file->folder_id)
-            ->where('source_file_id', $file->source_file_id)
-            ->orWhere('id', $file->source_file_id)
-            ->latest('version')
-            ->paginate($pageSize);
+        if (!empty($file->source_file_id)) {
+            $files = File::query()
+                ->with(['bimFile', 'createdBy'])
+                ->where('is_bim', 1)
+                ->where('object_type', $file->object_type)
+                ->where('object_id', $file->object_id)
+                ->where('folder_id', $file->folder_id)
+                ->where('source_file_id', $file->source_file_id)
+                ->orWhere('id', $file->source_file_id)
+                ->latest('version')
+                ->paginate($pageSize);
+        } else {
+            $files[] = $file;
+        }
 
         return FileSimpleResource::collection($files);
     }