|
@@ -26,22 +26,18 @@ class FolderController extends Controller
|
|
|
/**
|
|
|
* Display a listing of the resource.
|
|
|
*/
|
|
|
- public function tree(string $objectType, string $objectId)
|
|
|
+ public function tree(string $objectType, string $objectId, $parentFolderId = 0)
|
|
|
{
|
|
|
$folderObjectType = FolderObjectType::from($objectType);
|
|
|
|
|
|
$object=$folderObjectType->modelBuilderAllowed()->with(['library'])->findOrFail($objectId);
|
|
|
|
|
|
- $folders = Folder::query()
|
|
|
+ $folders = Folder::withCount('children')
|
|
|
->where([
|
|
|
'object_type' => $objectType,
|
|
|
'object_id' => $objectId,
|
|
|
])
|
|
|
- // ->when(request("parent_id", 0) > 0, function ($query) {
|
|
|
- // return $query->where("path", "like", "%," . \request("parent_id") . ",%")->where("id", "!=", \request("parent_id"));
|
|
|
- // })
|
|
|
- // 文件夹树暂时显示一层
|
|
|
- ->where('parent_id',0)
|
|
|
+ ->where('parent_id', $parentFolderId)
|
|
|
->orderByDesc("sequence")
|
|
|
->get([
|
|
|
'id',
|
|
@@ -64,7 +60,6 @@ class FolderController extends Controller
|
|
|
];
|
|
|
|
|
|
return $this->success([
|
|
|
- //'data' => make_tree($folders->toArray(), \request("parent_id", 0)),
|
|
|
'object'=> $container,
|
|
|
'data' => $folders
|
|
|
]);
|