mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
fixed moving issue when user move folder with files into team folder
This commit is contained in:
@@ -1,24 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\Items\Actions;
|
namespace Domain\Items\Actions;
|
||||||
|
|
||||||
use Gate;
|
use Domain\Teams\Actions\SetTeamFolderPropertyForAllChildrenAction;
|
||||||
|
use Domain\Folders\Models\Folder;
|
||||||
use Domain\Sharing\Models\Share;
|
use Domain\Sharing\Models\Share;
|
||||||
|
use Gate;
|
||||||
|
|
||||||
class MoveFileOrFolderAction
|
class MoveFileOrFolderAction
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
public SetTeamFolderPropertyForAllChildrenAction $setTeamFolderPropertyForAllChildren,
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move folder or file to new location
|
* Move folder or file to new location
|
||||||
*/
|
*/
|
||||||
public function __invoke($request, ?Share $share = null): void
|
public function __invoke($request, ?Share $share = null): void
|
||||||
{
|
{
|
||||||
foreach ($request->input('items') as $item) {
|
foreach ($request->input('items') as $item) {
|
||||||
$item = get_item($item['type'], $item['id']);
|
$entry = get_item($item['type'], $item['id']);
|
||||||
|
|
||||||
Gate::authorize('can-edit', [$item, $share]);
|
|
||||||
|
|
||||||
$item->update([
|
// Check permission
|
||||||
'parent_id' => $request->input('to_id'),
|
Gate::authorize('can-edit', [$entry, $share]);
|
||||||
]);
|
|
||||||
|
// Process folder
|
||||||
|
if ($item['type'] === 'folder') {
|
||||||
|
|
||||||
|
// Determine, if we are moving folder into the team folder or not
|
||||||
|
$isTeamFolder = is_null($request->input('to_id'))
|
||||||
|
? false
|
||||||
|
: Folder::find($request->input('to_id'))->getLatestParent()->team_folder;
|
||||||
|
|
||||||
|
// Change team_folder mark for all children folders
|
||||||
|
($this->setTeamFolderPropertyForAllChildren)($entry, $isTeamFolder);
|
||||||
|
|
||||||
|
// Update folder
|
||||||
|
$entry->update([
|
||||||
|
'parent_id' => $request->input('to_id'),
|
||||||
|
'team_folder' => $isTeamFolder,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process file
|
||||||
|
if ($item['type'] !== 'folder') {
|
||||||
|
// Update file
|
||||||
|
$entry->update([
|
||||||
|
'parent_id' => $request->input('to_id'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user