|
@@ -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);
|
|
|
}
|