Add the "move nodes" feature

This commit is contained in:
brufdev
2025-02-23 18:42:51 +00:00
parent 761dd44bc4
commit 72ff12ecd4

View File

@@ -11,11 +11,11 @@ final readonly class UpdateVaultNode
{
/**
* @param array{
* parent_id: int|null,
* is_file: bool,
* name: string,
* extension: string|null,
* content: string|null
* parent_id?: int|null,
* is_file?: bool,
* name?: string,
* extension?: string|null,
* content?: string|null
* } $attributes
*/
public function handle(VaultNode $node, array $attributes): void
@@ -30,12 +30,16 @@ final readonly class UpdateVaultNode
Storage::disk('local')->put($originalPath, $attributes['content'] ?? '');
}
if (!$node->wasChanged('name')) {
return;
// Rename node on disk
if ($node->wasChanged('name')) {
$path = new GetPathFromVaultNode()->handle($node);
Storage::disk('local')->move($originalPath, $path);
}
// Rename node on disk
$path = new GetPathFromVaultNode()->handle($node);
Storage::disk('local')->move($originalPath, $path);
// Move node on disk
if ($node->wasChanged('parent_id')) {
$path = new GetPathFromVaultNode()->handle($node);
Storage::disk('local')->move($originalPath, $path);
}
}
}