Refactor code

This commit is contained in:
brufdev
2025-02-26 19:51:39 +00:00
parent a881885526
commit 6f4df0dc9a
2 changed files with 1 additions and 11 deletions
+1 -9
View File
@@ -12,9 +12,7 @@ final readonly class UpdateVaultNode
/**
* @param array{
* parent_id?: int|null,
* is_file?: bool,
* name?: string,
* extension?: string|null,
* content?: string|null
* } $attributes
*/
@@ -31,13 +29,7 @@ final readonly class UpdateVaultNode
}
// Rename node on disk
if ($node->wasChanged('name')) {
$path = new GetPathFromVaultNode()->handle($node);
Storage::disk('local')->move($originalPath, $path);
}
// Move node on disk
if ($node->wasChanged('parent_id')) {
if ($node->wasChanged(['name', 'parent_id'])) {
$path = new GetPathFromVaultNode()->handle($node);
Storage::disk('local')->move($originalPath, $path);
}
-2
View File
@@ -99,9 +99,7 @@ final class VaultNodeForm extends Form
new UpdateVaultNode()->handle($this->node, [
'parent_id' => $this->parent_id,
'is_file' => (bool) $this->node->is_file,
'name' => $this->name,
'extension' => $this->node->extension,
'content' => $this->content,
]);