mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 19:10:40 +00:00
api resource refactoring part 5
This commit is contained in:
@@ -32,8 +32,9 @@ class BrowseTrashContentController
|
||||
|
||||
// Collect folders and files to single array
|
||||
return [
|
||||
'content' => collect([$folders, $files])->collapse(),
|
||||
'folder' => $requestedFolder,
|
||||
'folders' => new FolderCollection($folders),
|
||||
'files' => new FilesCollection($files),
|
||||
'root' => $requestedFolder,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,17 @@ class FileResource extends JsonResource
|
||||
$this->mergeWhen($this->shared, fn() => [
|
||||
'shared' => new ShareResource($this->shared),
|
||||
]),
|
||||
$this->mergeWhen($this->parent, fn() => [
|
||||
'parent' => [
|
||||
'data' => [
|
||||
'type' => 'folder',
|
||||
'id' => $this->parent->id,
|
||||
'attributes' => [
|
||||
'name' => $this->parent->name,
|
||||
],
|
||||
],
|
||||
],
|
||||
]),
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
@@ -43,6 +43,17 @@ class FolderResource extends JsonResource
|
||||
$this->mergeWhen($this->shared, fn() => [
|
||||
'shared' => new ShareResource($this->shared),
|
||||
]),
|
||||
$this->mergeWhen($this->parent, fn() => [
|
||||
'parent' => [
|
||||
'data' => [
|
||||
'type' => 'folder',
|
||||
'id' => $this->parent->id,
|
||||
'attributes' => [
|
||||
'name' => $this->parent->name,
|
||||
],
|
||||
],
|
||||
],
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user