mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
public share navigation
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Domain\Browsing\Controllers;
|
||||
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
||||
use Domain\Sharing\Actions\VerifyAccessToItemAction;
|
||||
|
||||
/**
|
||||
* Browse shared folder
|
||||
*/
|
||||
class VisitorBrowseFolderController
|
||||
{
|
||||
public function __construct(
|
||||
private ProtectShareRecordAction $protectShareRecord,
|
||||
private VerifyAccessToItemAction $verifyAccessToItem,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
string $id,
|
||||
Share $shared,
|
||||
): array {
|
||||
|
||||
// Check ability to access protected share record
|
||||
($this->protectShareRecord)($shared);
|
||||
|
||||
// Check if user can get directory
|
||||
($this->verifyAccessToItem)($id, $shared);
|
||||
|
||||
$requestedFolder = Folder::findOrFail($id);
|
||||
|
||||
// Get files and folders
|
||||
$folders = Folder::where('user_id', $shared->user_id)
|
||||
->where('parent_id', $id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
$files = File::where('user_id', $shared->user_id)
|
||||
->where('folder_id', $id)
|
||||
->sortable()
|
||||
->get();
|
||||
|
||||
// Set thumbnail links for public files
|
||||
$files->map(fn ($file) => $file->setPublicUrl($shared->token));
|
||||
|
||||
// Collect folders and files to single array
|
||||
return [
|
||||
'content' => collect([$folders, $files])->collapse(),
|
||||
'folder' => $requestedFolder,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user