mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-20 08:52:15 +00:00
current folder functionality
This commit is contained in:
@@ -12,9 +12,11 @@ class BrowseFolderContentController
|
||||
public function __invoke(
|
||||
Request $request,
|
||||
string $id,
|
||||
): Collection {
|
||||
): array {
|
||||
$root_id = $id === 'undefined' ? null : $id;
|
||||
|
||||
$requestedFolder = $root_id ? Folder::findOrFail($root_id) : null;
|
||||
|
||||
// Get folders and files
|
||||
$folders = Folder::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||
->where('parent_id', $root_id)
|
||||
@@ -29,7 +31,9 @@ class BrowseFolderContentController
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])
|
||||
->collapse();
|
||||
return [
|
||||
'content' => collect([$folders, $files])->collapse(),
|
||||
'folder' => $requestedFolder,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ namespace Domain\Browsing\Controllers;
|
||||
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class BrowseTrashContentController
|
||||
{
|
||||
public function __invoke(string $id): Collection
|
||||
public function __invoke(string $id): array
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
$root_id = $id === 'undefined' ? null : $id;
|
||||
$requestedFolder = $root_id ? Folder::withTrashed()->findOrFail($root_id) : null;
|
||||
|
||||
if ($root_id) {
|
||||
|
||||
@@ -29,8 +29,10 @@ class BrowseTrashContentController
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files])
|
||||
->collapse();
|
||||
return [
|
||||
'content' => collect([$folders, $files])->collapse(),
|
||||
'folder' => $requestedFolder,
|
||||
];
|
||||
}
|
||||
|
||||
// Get folders and files
|
||||
@@ -58,7 +60,9 @@ class BrowseTrashContentController
|
||||
->get();
|
||||
|
||||
// Collect folders and files to single array
|
||||
return collect([$folders, $files_trashed])
|
||||
->collapse();
|
||||
return [
|
||||
'content' => collect([$folders, $files_trashed])->collapse(),
|
||||
'folder' => $requestedFolder,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
* @method static whereUserId(int|string|null $id)
|
||||
* @method static find(mixed $id)
|
||||
* @method static where(string $string, string $user_id)
|
||||
* @method static findOrFail(string $root_id)
|
||||
* @property string id
|
||||
* @property string user_id
|
||||
* @property string parent_id
|
||||
|
||||
Reference in New Issue
Block a user